nginx + php-fpm "modern configuration way"

locojohn nginx-forum at nginx.us
Tue Apr 3 21:12:33 UTC 2012


Well, in that case you may as well support SCRIPT_URL / SCRIPT_URI, as
there are some [old] PHP scripts that rely on these variables set
normally by Apache.

nginx.conf:

http {
  ...
  map $uri $script_url {
          ~^(?<script_filename>.+\.(php|html))(?<path_info>.+)$
$path_info;
          ~^(?<script_filename>.+\.(php|html))$ $script_filename;
   }
  ...
}

fastcgi_php.conf:

include fastcgi_params;

          fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
          fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
          fastcgi_param PATH_INFO $fastcgi_path_info;
          fastcgi_param PATH_TRANSLATED
$document_root$fastcgi_path_info;

          fastcgi_param  SCRIPT_URL $script_url;
          fastcgi_param  SCRIPT_URI $scheme://$http_host$script_url;

          try_files $fastcgi_script_name = 404;

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



More information about the nginx mailing list