Zendframe Pathinfo 模块
闲言少叙:
环境:
Ubuntu12.04,
Nginx/1.1.19 php-fpm
PHP-5.3.1
1. 修改 php5/fpm/php.ini 在
; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's
; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
; this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting
; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting
; of zero causes PHP to behave as before. Default is 1. You should fix your scripts
; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
; http://php.net/cgi.fix-pathinfo
;cgi.fix_pathinfo=1
cgi.fix_pathinfo=0
2. 修改nginx.conf,注释掉 原有的 location ~\.php { }
location ~ \.php(/|$) {
fastcgi_split_path_info ^(.+\.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;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-cgi alone:
fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
# fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
3. 修改nginx.conf 平及目录下的fastcgi_param
注释掉 下面这行,如果没注释掉的话,pathinfo模式会报 AccessDenied
# fastcgi_param SCRIPT_FILENAME $request_filename;
因为
设置fastcgi_param SCRIPT_NAME $fastcgi_script_name;
php-cgi如果找不到文件或者没有权限访问的话 会提示No input file specified. 或者Access denied.
这样就OK了。