Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 have installed nginx on my Ubunut 12.04, I am not able to change the root directory for the nginx,

This is the default nginx configuration file:

server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        #root /usr/share/nginx/html;
        root /var/www
        index index.html index.htm;

        server_name localhost;

        location / {
                try_files $uri $uri/ =404;

I tried changing root to /var/www/ but some how it doesn't want to change. I tried restarting the nginx but I am not able to change the root directory.

share|improve this question
Use command nginx -t to check for syntax errors. – Alexey Ten Jun 11 '14 at 10:44
@AlexeyTen Thanks for the tips :) – shrish Jun 11 '14 at 10:48
up vote 7 down vote accepted

Your configuration is missing the ; at the end of root directive.

Try this:

root /var/www;
share|improve this answer
Wow.. you got me there, that works.. thanks for the quick reply :) getting rid of Apache was hurting me.. thanks a lot – shrish Jun 11 '14 at 10:40

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.