Nginx 支持 pathinfo

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了。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值