2017-10-20 84 views
0

这里是我的/usr/local/nginx/conf/nginx.conf:为什么nginx位置返回404错误?

server { 
     listen  8080; 
     server_name localhost; 

     location/{ 
      root html; 
      index index.html index.htm; 
     } 

     location /test{ 
       root /var/www/test; 
       index index.html index.htm; 
     } 

当我键入:http://localhost:8080/:我nginx的欢迎页面:好

当我在http://localhost:8080/test键入:我得到了一个404错误 (我创建的index.html和里面的/ var/WWW/index.htm的测试)

PS我没有与重装:

/usr/local/nginx/sbin/nginx -s reload 

回答

1

删除/test到根指令。您只需注明/var/www

server { 
    listen  8080; 
    server_name localhost; 

    location/{ 
     root html; 
     index index.html index.htm; 
    } 

    location /test { 
     root /var/www; 
     index index.html index.htm; 
    } 
+0

当然,我确实重新加载了。你能告诉我更多关于权利和所有者吗? – yarek

+0

NGinx服务器与哪个用户一起运行? – Indent

+0

Nginx以root用户身份运行。 nginx似乎可以:当我将端口8080更改为8089时,我需要去lcoalhost:8089。奇怪的是:当我评论指令“位置/”时,我仍然可以去/位置 – yarek