Nginx:无法查看索引 html

Nginx:无法查看索引 html

我使用 Ubuntu 13.10 + nginx(来自 repos),但遇到一个问题:我无法在浏览器中看到我的本地 index.hmtl(借助 nginx)。

安装:

sudo apt-get install nginx

为我的静态文件创建目录

sudo mkdir /opt/nginx/files && sudo mkdir /opt/nginx/img
sudo chown www-data:www-data /opt/nginx/

/opt/nginx$ ls -la

drwxr-xr-x 4 www-data www-data 4096 oct.  31 19:57 .
drwxr-xr-x 8 www-data www-data 4096 oct.  31 19:57 ..
drwxr-xr-x 2 root     root     4096 oct.  31 20:02 files
drwxr-xr-x 2 root     root     4096 oct.  31 19:57 img

/etc/nginx/nginx.conf

user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    gzip_vary on;
    # gzip_proxied any;
    gzip_comp_level 6;
    # gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # nginx-naxsi config
    ##
    # Uncomment it if you installed nginx-naxsi
    ##

    #include /etc/nginx/naxsi_core.rules;

    ##
    # nginx-passenger config
    ##
    # Uncomment it if you installed nginx-passenger
    ##

    #passenger_root /usr;
    #passenger_ruby /usr/bin/ruby;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

    server {
                listen       80;
                server_name  filestorange;
                error_page   404        /404.html;

                #access_log  logs/localhost.access.log  main;

                location / {
                    root   /opt/nginx/files;
                    index  index.html;
                }
                location /404.html {
                root /opt/nginx/files;
        } 
        }
    }   

然后我用

    sudo nginx -s reload
    sudo service nginx restart

但在localhost浏览器中我看到:If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

我需要查看我的 index.html 文件(位于/opt/nginx/files)。如何修复?谢谢!

答案1

我的猜测是sudo chown -R www-data:www-data /opt/nginx/

我没有在任何地方看到您的 index.html

相关内容