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.


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.

  • 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. – CRK Mar 14 '14 at 3:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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