FastCGI PHP No input file specified

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:
http://forum.nginx.org/read.php?2,177494,177494#msg-177494

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. [email protected]

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.
http://sysoev.ru/en/

Why don’t you follow the example at
http://wiki.nginx.org/Zend_Framework#Time_for_nginx where all requests
to *.php are sent to the backend?

Thank you.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,177494,179065#msg-179065

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs