如何修复 nginx 配置上的“404 not found”错误

sal*_*fek 4 nginx http-status-code-404

我刚刚在 debian 上安装了 nginx,并在 nginx.conf 文件中进行了基本配置(添加服务器部分)

user www-data;
worker_processes  1;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
    # multi_accept on;
}

http {
    include       /etc/nginx/mime.types;
    default_type application/octet-stream;
    access_log  /var/log/nginx/access.log;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
#    tcp_nodelay        on;

#    gzip  on;
#    gzip_disable "MSIE [1-6]\.(?!.*SV1)";

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

    server {
        listen 80;
        server_name localhost;
        location / {
                root html;
                index index.html index.htm;
        }
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root html;
        }
    }
}

# mail {
#     # See sample authentication script at:
#     # http://wiki.nginx.org/NginxImapAuthenticateWithApachePhpScript
#
#     # auth_http localhost/auth.php;
#     # pop3_capabilities "TOP" "USER";
#     # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#     server {
#         listen     localhost:110;
#         protocol   pop3;
#         proxy      on;
#     }
#
#     server {
#         listen     localhost:143;
#         protocol   imap;
#         proxy      on;
#     }
# }
Run Code Online (Sandbox Code Playgroud)

我总是收到 index.html 页面插入的“404 Not Found”错误消息。

Nginx 安装文件夹是

/etc/nginx 
Run Code Online (Sandbox Code Playgroud)

配置文件在

/etc/nginx/nginx.conf 
Run Code Online (Sandbox Code Playgroud)

和 index.html 和 50x.html 中

/etc/nginx/html 
Run Code Online (Sandbox Code Playgroud)

文件夹。

我究竟做错了什么?谢谢。

Hrv*_*jar 7

我没有看到document_rootroot设置为 index.html 所在的路径;将它们设置为 index.html 所在的相应路径,所有这些都应该可以工作。