FastCGI PHP No input file specified.

Francis Daly francis at
Tue Feb 22 21:05:55 MSK 2011

On Tue, Feb 22, 2011 at 11:14:23AM -0500, alexk wrote:

Hi there,

You have a bit of duplication in your config. Depending on what exactly
is included in the ".." part, it may be easier on the eyes to shrink
it a bit. But that's not immediately important here.

> I have Zend Framework project working so all non static requests are
> forwarded to public/index.php. But now I need to allow PHP scripts from
> another folder - /generator/ to work as usual. So I've added another
> location and use "fastcgi_param   SCRIPT_FILENAME
> /var/www/new/public/generator$fastcgi_script_name;"

$fastcgi_script_name is something like "/generator/env.php". Plugging that
in above, you probably don't end up with a valid filename on your system.

You rarely want anything other than

  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

If you're using something else, you should have a good reason to.

As it happens, you *do* have a good reason to, in your first location{}
block. But not in your second.

The only difference between fastcgi_params and fastcgi.conf is
the addition of that line (at least in 0.8.54). So if you include
fastcgi.conf, you don't even need to add that line.

>         location / {
>                 root   /var/www/new/public;

If most things are under the same document root, it is simpler to put
"root" outside all locations.

>                 fastcgi_pass;
>                 fastcgi_index  index.php;

Since everything in this location{} is sent with the same SCRIPT_FILENAME,
I don't *think* that this fastcgi_index and the later index, do anything.

>                 fastcgi_store           off;
>                 fastcgi_store_access    user:rw  group:rw  all:r;
>                 charset utf-8;
>                 fastcgi_param  SCRIPT_FILENAME
> /var/www/new/public/index.php;

You could use $document_root/index.php there. The main advantage is that
when you relocate the whole document root, you only need change the one
"root" directive.

>                 include        fastcgi_params;

In this case, you *did* need to set "fastcgi_param  SCRIPT_FILENAME"
to something, and so you also need to "include fastcgi_params" (or
"include fastcgi.conf") in this location.

But if you also "include fastcgi.conf" outside all locations, up there
with the moved "root", then...

>         location /generator/ {
>                 fastcgi_pass;

...that much would have been enough to get this working. At least,
for requests like /generator/file.php. If you want requests like
/generator/dir/ to work you'd also need a fastcgi_index set. (Which,
if it is the same in most locations, could also live outside of all
locations and be inherited automagically.)

>                 fastcgi_param   SCRIPT_FILENAME
> /var/www/new/public/generator$fastcgi_script_name;
>                 include         fastcgi_params;

If you really really want to change the smallest amount in your
config file, just erase "/generator" up there, and consider adding
a fastcgi_index.

But I'd suggest doing more -- this location{} currently uses the
compiled-in $document_root, for example, which is probably not what
you want.

Good luck with it,

Francis Daly        francis at

More information about the nginx mailing list