开发者

nginx and trailing slashes on $document_root?

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_FILENAM开发者_JS百科E $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?


Just faced the same issue (in remi installation of nginx+php-fpm on a RHEL6 server), you can solve it by adding the following line in /etc/nginx/fastcgi_params

fastcgi_param  SCRIPT_FILENAME    $request_filename;

I found this line missing in RHEL, while present in a perfectly working Debian nginx.


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.


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


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.


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜