0

I want to run nginx on my Ubuntu 10.04 32bit Linode VPS.

sudo chown -R www-data:www-data /var/www
sudo chmod -R 775 /var/www

sudo add-apt-repository ppa:nginx/development
sudo apt-get update
sudo apt-get install nginx

To make a nginx virtualhost:

mkdir -p /var/www/example.com/{public,logs}
sudo nano /etc/nginx/sites-available/example.com

and wrote following

server {
     listen   80;
     server_name  www.example.com;
     rewrite ^/(.*) http://example.com/$1 permanent;
     }

server {
     listen   80;
     server_name example.com;

     access_log /var/www/example.com/logs/access.log;
     error_log /var/www/example.com/logs/error.log;

     location / {
          root   /var/www/example.com/public/;
          index  index.html;
          }
}

Then I enabled the virtualhost example.com

sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/example.com
sudo /etc/init.d/nginx restart

I put a index.html to /var/www/example.com/public and enter example.com URL from my browser. Then I got following

403 Forbidden
nginx/0.8.53

tail /var/log/nginx/error.log gives following error

*38 directory index of "/var/www/" is forbidden, client: 88.224.1.128, server: localhost, request: "GET / HTTP/1.1", host: www.example.com

I redo

sudo chown -R www-data:www-data /var/www
sudo chmod -R 775 /var/www

but it gives same error.

and cat /etc/nginx/nginx.cnf

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;

    access_log  /var/log/nginx/access.log;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay        on;

    gzip  on;
    # As per: http://wiki.nginx.org/NginxHttpGzipModule#gzip_disable starting
    # with 0.7.63
    gzip_disable     "msie6";

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

If I put the index.html to /var/www/ then I can see html file but any attempt to put it under /var/www/example.com/public fails. I looked at file and folder permissions they are ok all belongs to www-data and readable (775)

What can I do to make nginx work? Thanks

3 Answers 3

2

There is probably another file in the sites-enabled directory, with a servername wildcard? And my guess is that this configuration has a root directory of "/var/www"?

0

Did you reload the configuration files? Nginx does not parse the configuration file on every load like Apache does with htaccess, you have to actively send it the reload (HUP) command.

0

On Ubuntu the reload command will be

/etc/init.d/nginx reload

If installed via apt, if not then try

/path/to/nginx reload

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .