views:

730

answers:

5

I use the following configuration for nginx: http://gist.github.com/340956

However, this configuration causes a No input file specified error with PHP. The only way I have been able to solve it is by altering this line:

fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;

Note the "/" between $document_root and $fastcgi_script_name. I was informed that this is the wrong configuration but no one has been able to tell me exactly why my configuration requires this extra slash.

How can I get rid of that extra slash?

A: 

Remove try_files $uri index.php$uri; in line 3.

SpawnCxy
Then my rewriting breaks, as I have URLs like `/foo/bar` which redirect to `index.php/foo/bar`.
shadowhand
A: 

Matter of preference. As long as you are consistent, either way is fine.

Either add the slash in the configuration file, and ensure there are no additional slashes at the end and start of the document root and script name respectively or vice versa.

enbuyukfener
I don't buy it. It seems to make no difference whether I add a trailing slash to $root or not.
shadowhand
A: 

does 'root' in your defaults.conf point to the same path as your "open_basedir" option in php.ini?

Jamie
No, of course not. I have multiple domains with a single php.ini hosted on a single machine.
shadowhand
+1  A: 

Does the param PATH_TRANSLATED get the correct URI? I'm thinking it's the immediate concatenating of the variables in the conf file that doesn't compute. When adding a slash between them, maybe they are interpreted correctly.

When you get the error No input file specified, check your log to see what URI was requested.

Simeon
What log should I check when I get a `No input file specified` error? nginx logs don't show anything, as the error is triggered by PHP.
shadowhand
There is no `PATH_TRANSLATED` in my `$_SERVER` dump.
shadowhand
PHP error logs also show no errors.
shadowhand
The only thing that is logged by nginx is in the access log, and that just shows a "404" to any URL that uses rewriting.
shadowhand
Try this: http://nginx.org/en/docs/debugging_log.html
Simeon
The idea here is to find out what URI is requested
Simeon
A: 

what happens when you explicitly add a root directive like so:

location ~ \.php$ {
    # fastcgi_split_path_info ^(.+\.php)(.*)$;
    include fastcgi.conf;

    root /var/www/my_webroot;

    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
}
whitepixel
My `$root` is defined in `server { ... }` is that not good enough?
shadowhand