fastcgi server variables vs. apache
Igor Sysoev
igor at sysoev.ru
Wed Dec 16 16:55:55 MSK 2009
On Wed, Dec 16, 2009 at 08:40:17AM -0500, spirit wrote:
> @shizobuddy: /path/to/php is usually $document_root if set properly so you come up with the following generic config:
>
> fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
The slash is not needed:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
> @androo: instead of setting fastcgi_param in a if (in fact you can't), you can still set variables to do so. Example
>
>
> set $script index.php;
> set $path_info "";
> if ($uri ~ "^(.+\.php)(.*)") {
> set $script $1;
> set $path_info $2;
> }
> fastcgi_param PATH_INFO $path_info;
> ....
It's better to use fastcgi_split_path_info:
location ~ ^(.+\.php)(.*)$ {
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME /path/to/php$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
or named captures:
location ~ ^(?<script_name>.+\.php)(?<path_info>.*)$ {
fastcgi_param SCRIPT_FILENAME /path/to/php$script_name;
fastcgi_param PATH_INFO $path_info;
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list