# FastCGI PHP No input file specified

**URL:** <https://www.ruby-forum.com/t/fastcgi-php-no-input-file-specified/203544>\
**Category:** NGINX\
**Created:** [February 22, 2011, 5:15pm UTC](https://www.ruby-forum.com/t/fastcgi-php-no-input-file-specified/203544 "2011-02-22T17:15:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [February 22, 2011, 5:15pm UTC](https://www.ruby-forum.com/t/fastcgi-php-no-input-file-specified/203544/1 "2011-02-22T17:15:37Z")

</div>

Hi,

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

As a result it returns “No input file specified.”. Not sure what’s the  
problem is.

Thanks for any help. Here you are config file:

server {  
listen 80;  
server\_name \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*;

```
    gzip on;
    gzip_types text/html text/css application/x-javascript

```

application/javascript text/plain text/xml;

```
    charset utf-8;

    #access_log /var/log/nginx/localhost.access.log;

    location / {
            root /var/www/new/public;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;

            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;  
include fastcgi\_params;  
index index.php;  
}

```
    location /generator/ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_param SCRIPT_FILENAME

```

/var/www/new/public/generator$fastcgi\_script\_name;  
include fastcgi\_params;  
}

```
    location ~*

```

“(/userfiles/)|(.(xrd|log|pdf|ttf|fon|js|ico|txt|xml|html|dtd|gif|jpg|png|css|rss|zip|tar.gz))$”  
{  
root /var/www/new/public;  
expires max;  
}

…

}

Posted at Nginx Forum:

> **[FastCGI PHP No input file specified.](https://forum.nginx.org/read.php?2,177494,177494#msg-177494)**
>
> Hi, 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...

---

<div class="post-metadata">

**Author:** ![alexk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/91b2a8/32.png) [@alexk](https://www.ruby-forum.com/u/alexk)\
**Post date:** [February 22, 2011, 7:07pm UTC](https://www.ruby-forum.com/t/fastcgi-php-no-input-file-specified/203544/2 "2011-02-22T19:07:43Z")

</div>

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 127.0.0.1:9000;
> 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 127.0.0.1:9000;
> 
> ```

…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,

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![alexk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/91b2a8/32.png) [@alexk](https://www.ruby-forum.com/u/alexk)\
**Post date:** [February 22, 2011, 9:44pm UTC](https://www.ruby-forum.com/t/fastcgi-php-no-input-file-specified/203544/3 "2011-02-22T21:44:49Z")

</div>

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

> ```
> #access_log /var/log/nginx/localhost.access.log;
> 
> location / {
> root /var/www/new/public;
> fastcgi_pass 127.0.0.1:9000;
> fastcgi_index index.php;
> 
> ```

fastcgi\_index is useless here, because all requests are handled by  
“/var/www/new/public/index.php”

> ```
> fastcgi_store off;
> fastcgi_store_access user:rw group:rw all:r;
> 
> ```

fastcgi\_store/fastcgi\_store\_access are not needed here.

> ```
> charset utf-8;
> 
> fastcgi_param SCRIPT_FILENAME
> 
> ```
> 
> /var/www/new/public/index.php;  
> include fastcgi\_params;  
> index index.php;

“index” is useless here, because all requests are handled by  
fastcgi\_pass.

> ```
> }
> 
> location /generator/ {
> fastcgi_pass 127.0.0.1:9000;
> fastcgi_param SCRIPT_FILENAME
> 
> ```
> 
> /var/www/new/public/generator$fastcgi\_script\_name;  
> include fastcgi\_params;  
> }

When you request “/generator/script.php”, SCRIPT\_FILENAME is equal  
to “/var/www/new/public/generator/generator/script.php”. You should  
remove “/generator” from fastcgi\_param SCRIPT\_FILENAME:

fastcgi\_param SCRIPT\_FILENAME  
/var/www/new/public$fastcgi\_script\_name;

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![alexk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/91b2a8/32.png) [@alexk](https://www.ruby-forum.com/u/alexk)\
**Post date:** [February 22, 2011, 5:23pm UTC](https://www.ruby-forum.com/t/fastcgi-php-no-input-file-specified/203544/4 "2011-02-22T17:23:08Z")

</div>

Why don’t you follow the example at  
[Zend Framework | NGINX](http://wiki.nginx.org/Zend_Framework#Time_for_nginx) where all requests  
to \*.php are sent to the backend?

---

<div class="post-metadata">

**Author:** ![alexk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/91b2a8/32.png) [@alexk](https://www.ruby-forum.com/u/alexk)\
**Post date:** [February 28, 2011, 11:06am UTC](https://www.ruby-forum.com/t/fastcgi-php-no-input-file-specified/203544/5 "2011-02-28T11:06:02Z")

</div>

Thank you.

Posted at Nginx Forum:

> **[Re: FastCGI PHP No input file specified.](https://forum.nginx.org/read.php?2,177494,179065#msg-179065)**
>
> Hi, 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...
