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

I'm very experienced with Apache, but I wanted to make the switch to Nginx to try and gain experience with a very popular piece of software. Unfortunately I have not gotten very far and this problem is driving me crazy.

After putting up a test page (just a simple): echo "This is Nginx";

I decompressed my .tar.gz file and loaded all the web files into the directory - I check the permissions too, btw. Unfortunately all I can see is still "This is Nginx"

Thus far I have:

  • Restarted Nginx
  • Restarted php5-fpm (yes, I know there are several ways for different systems, I tried them all)
  • Made sure the file permissions are correct
  • Reviewd my config files and server block (see below) and,
  • Turned off the sendfile option in nginx.conf

My server block looks as follows:

server {
    listen   80;
    server_name xxx;
    access_log  /var/log/nginx/localhost.access.log;

## Default location
location / {
    root   /srv/www;
    index  index.php;
}

## Images and static content is treated different
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
  access_log        off;
  expires           30d;
  root /srv/www;
}

## Parse all .php file in the /var/www directory
location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) {
            return 404;
    }
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
}

## Disable viewing .htaccess & .htpassword
location ~ /\.ht {
    deny  all;
}
}

My nginx.conf file is the same as the default, less the SendFile change pointed out above. Any help someone can offer would be much appreciated.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

You forgot to declare root within your server block. You only have it repeated in some location blocks. This is one of the most common nginx misconfigurations. Move them out to the server block.

share|improve this answer
    
Once again (I'm pretty sure you've answered my questions before) thank you Michael Hampton. This problem was driving me insane, but like I figured it turned out to be an easy fix. Much appreciated. –  user2085959 Mar 14 at 3:12

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.