Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

What I am trying to do is setup a web server for development running in VMware with the IP address of 192.168.190.128. Nginx is installed and running and I get the "welcome to nginx" page.

However when I create a subfolder in "var/www" and try to hit "http://192.168.190.128/subfolder" I get a 404 Not found error. The files are owned by www-data, and nginx is running on that account also so I dont think its a permissions issue.

Here is my nginx configuration.

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/*;
}

Here is the default server config in sites enabled:

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;
    }
}
share|improve this question
    
Did you create an index page in the subdirectory? –  Shane Madden Dec 22 '11 at 1:20
    
Check (and post relevant sections of) your error.log for details on which file nginx tried to access (possibly increase the verbosity of the error.log, by adding 'info' to the end of the line). There is some chance you have multiple servers defined as default (are there any other servers in: /etc/nginx/conf.d/?) –  cyberx86 Dec 22 '11 at 1:25
    
Ah, its looking in /var/www/nginx-default. instead of /var/www/ as root directory. –  Jordan Dec 22 '11 at 1:29

2 Answers 2

up vote 3 down vote accepted

Nginx's default root directory for Ubuntu is /var/www/nginx-default and not /var/www

Quite a surprise for those accustomed to Debian 6's /var/www default with the Nginx package.

share|improve this answer
    
Solved my problem, thank you! –  Jordan Dec 22 '11 at 2:09

I think, that you can choose another directory then /var/www/nginx-default, but you must use this directive:

root /var/www;

instead of

root /var/www/;
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.