Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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/{public,logs}
sudo nano /etc/nginx/sites-available/

and wrote following

server {
     listen   80;
     rewrite ^/(.*)$1 permanent;

server {
     listen   80;

     access_log /var/www/;
     error_log /var/www/;

     location / {
          root   /var/www/;
          index  index.html;

Then I enabled the virtualhost

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

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

403 Forbidden

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

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

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

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: 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/ 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

share|improve this question

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"?

share|improve this answer

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.

share|improve this answer

On Ubuntu the reload command will be

/etc/init.d/nginx reload

If installed via apt, if not then try

/path/to/nginx reload
share|improve this answer

Your Answer


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.