Nginx + PHP - No input file specified

Posted by F21 on Server Fault See other posts from Server Fault or by F21
Published on 2012-12-19T05:03:31Z Indexed on 2012/12/19 5:04 UTC
Read the original article Hit count: 395

Filed under:
|
|

I am running Ubuntu Desktop 12.04 with nginx 1.2.6. PHP is PHP-FPM 5.4.9.

This is the relevant part of my nginx.conf:

http {
    include       mime.types;

    default_type  application/octet-stream;

    sendfile        on;

    root /www

    keepalive_timeout  65;

    server {

       server_name testapp.com;
       root /www/app/www/;
       index index.php index.html index.htm;

       location ~ \.php$ {

        fastcgi_intercept_errors on;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
       }
    }

    server {
        listen       80  default_server;
        index index.html index.php;

        location ~ \.php$ {
          fastcgi_intercept_errors on;
          fastcgi_pass   127.0.0.1:9000;
          fastcgi_index  index.php;
          fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
          include        fastcgi_params;
        }
    }
}

In my hosts file, I redirect 2 domains: testapp.com and test.com to 127.0.0.1.

My web files are all stored in /www.

From the above settings, if I visit test.com/phpinfo.php and test.com/app/www, everything works as expected and I get output from PHP.

However, if I visit testapp.com, I get the dreaded No input file specified. error.

So, at this point, I pull out the log files and have a look:

2012/12/19 16:00:53 [error] 12183#0: *17 FastCGI sent in stderr: "Unable to open primary script: /www/app/www/index.php (No such file or directory)" while reading response header from upstream, client: 127.0.0.1, server: testapp.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "testapp.com"

This baffles me because I have checked again and again and /www/app/www/index.php definitely exists! This is also validated by the fact that test.com/app/www/index.php works which means the file exists and the permissions are correct.

Why is this happening and what are the root causes of things breaking for just the testapp.com v-host?

© Server Fault or respective owner

Related posts about nginx

Related posts about configuration