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

    keepalive_timeout  65;

    server {

       root /www/app/www/;
       index index.php index.html index.htm;

       location ~ \.php$ {

        fastcgi_intercept_errors on;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;

    server {
        listen       80  default_server;
        root /www
        index index.html index.php;

        location ~ \.php$ {
          fastcgi_intercept_errors on;
          fastcgi_index  index.php;
          fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
          include        fastcgi_params;

Relevant bits from php-fpm.conf:

; Chroot to this directory at the start. This value must be defined as an
; absolute path. When this value is not set, chroot is not used.
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
; of its subdirectories. If the pool prefix is not set, the global prefix
; will be used instead.
; Note: chrooting is a great security feature and should be used whenever 
;       possible. However, all PHP paths will be relative to the chroot
;       (error_log, sessions.save_path, ...).
; Default Value: not set
;chroot = 

; Chdir to this directory at the start.
; Note: relative path can be used.
; Default Value: current directory or / when chroot
chdir = /www

In my hosts file, I redirect 2 domains: and to

My web files are all stored in /www.

From the above settings, if I visit and, everything works as expected and I get output from PHP.

However, if I visit, 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:, server:, request: "GET / HTTP/1.1", upstream: "fastcgi://", host: ""

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 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 v-host?

Just an update to my investigation:

I have commented out chroot and chdir in php-fpm.conf to narrow down the problem

If I remove the location ~ \.php$ block for, then nginx will send me a bin file which contains the PHP code. This means that on nginx's side, things are fine.

The problem is that something must be mangling the file paths when passing it to PHP-FPM.

Having said that, it is quite strange that the default_server v-host works fine because its root is /www, where as things just won't work for the v-host because the root is /www/app/www.

share|improve this question
up vote 3 down vote accepted

Problem solved.

In my php.ini, I had:

doc_root = /www;

This meant that all php request would have /www added to the beginning of the file, which was causing problems. I have also since commented out chroot and chdir in php-fpm.conf as they will also add extra bits to the beginning of file paths.

So far everything works, however, I will be doing more research for getting chroot and chdir to work to secure the installation.

share|improve this answer

So, for you're hitting the first server block which has the documentroot of /www/app/www.

For you're hitting /www, and then hoping that FPM figures out you wanna go to /www/www/app/www/index.php

Which is not going to happen. Can you share the specifics of your fpm config? Specifically the chroot and chdir part?

share|improve this answer
Can you elaborate why it is not going to happen? has a root of /www where as has a root of /www/app/www. I have updated my question as well :) – F21 Dec 19 '12 at 5:40
try changing the chdir to just /. How nginx passes the variables, and how fpm reads the path are completely different. When you set the chdir to be /www, and then nginx sends something to fpm, it assumes the path nginx is sending, is AFTER the /www already. with a chdir of /www, sees it as /www/www/app/www, sees it as /www/www/ – Vid Luther Dec 19 '12 at 6:03
nope, still no dice :( – F21 Dec 19 '12 at 6:06

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.