加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

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

发布时间:2020-12-13 21:22:19 所属栏目:Nginx 来源:网络整理
导读:我刚刚在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 /

我刚刚在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;
#     }
# }

我总是得到index.html页面的“404 Not Found”错误消息.

Nginx安装文件夹是

/etc/nginx 

配置文件在

/etc/nginx/nginx.conf 

和index.html和50x.html in

/etc/nginx/html 

夹.

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

最佳答案
我没有看到document_root和root设置为index.html所在的路径;将这些设置为index.html所在的相应路径,并且所有路径都应该工作.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读