服务器运行的nginx+php,centos的系统。因需新部署一个网站,需要配置nginx支持pathinfo功能。网上各种查资料,终于搞定。
首先查看php.ini文件,查找cgi.fix_pathinfo=0,如不是0,改为0.重启php程序。
然后修改nginx配置文件:
location ~ \.php { ------(去掉php后面的$)
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
set $path_info "";
set $real_script_name $fastcgi_script_name;
if ( $fastcgi_script_name ~ "^(.+?\.php)(/.+)$" ) {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
(红色字体部分为新加内容)
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
include fastcgi_params;
}
最后有include fastcgi_params,需要修改此文件:
#fastcgi_param SCRIPT_NAME $fastcgi_script_name; ----(注释掉此行)
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;----(如有此行也注释掉)
完成后,重启nginx即可实现nginx支持pathinfo功能。
本文出自 “叶落花开” 博客,请务必保留此出处http://linus1521.blog.51cto.com/1216391/1545187
原文地址:http://linus1521.blog.51cto.com/1216391/1545187