Ubuntu的服务器10.04 Nginx的404错误

我正在尝试的是在VMware中为IP地址192.168.190.128设置一个用于开发的Web服务器。 Nginx已经安装并正在运行,我得到了“welcome to nginx”页面。

但是,当我在“var / www”中创build一个子文件夹,并尝试点击“ http://192.168.190.128/subfolder ”我得到一个404找不到错误。 这些文件归www-data所有,而且nginx也在这个帐户上运行,所以我不认为它是一个权限问题。

这是我的nginxconfiguration。

user www-data; worker_processes 4; 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; 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/*; } 

以下是启用的站点中的默认服务器configuration:

 server { listen 80 default; server_name localhost; access_log /var/log/nginx/localhost.access.log; location / { root /var/www/; index index.html index.htm index.php; } location /doc { root /usr/share; autoindex on; allow 127.0.0.1; deny all; } location /images { root /usr/share; autoindex on; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # #error_page 500 502 503 504 /50x.html; #location = /50x.html { # root /var/www/nginx-default; #} # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { #proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { #fastcgi_pass 127.0.0.1:9000; #fastcgi_index index.php; #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; #includefastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; } } 

Nginx的Ubuntu默认根目录是/var/www/nginx-default而不是/var/www

对于那些习惯Debian 6的/var/www默认使用Nginx包的人来说,这是一个惊喜。

我想,你可以select另一个目录,然后/ var / www / nginx-default,但是你必须使用这个指令:

 root /var/www; 

代替

 root /var/www/;