这是一个ningx设置的问题,和TP无关。TP默认使用PATH_INFO来做CURD,而nginx默认设置不处理PATH_INFO,查看nginx可以看到出错日志:
2010/01/09 22:05:36 [error] 13988#9380: *3 CreateFile() "E:\company\home\labs\php\thinkphp\server\nginx-0.8.31/..\..\src/Examples/Form/index.php/Index/insert" failed (3: The system cannot find the path specified), client: 127.0.0.1, server: localhost, request: "POST /Examples/Form/index.php/Index/insert HTTP/1.1", host: "localhost", referrer: "http://localhost/Examples/Form/"
说明nginx把PATH_INFO当成了目录文件的一部份,所以找不到该文件。
解决方法一:修改TP设置,不使用PATH_INFO
解决方法二:修改nginx设置,支持PATH_INFO
本人使用CoreServer集成包,就以此为例, 修改nginx.conf和fastcgi-params
将
location ~ \.php$ {
修改为
location ~ \.php/?.*$ {
将
fastcgi_param SCRIPT_FILENAME $document_root2$fastcgi_script_name;
修改为
set $fastcgi_script_name2 $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $fastcgi_script_name2 $1;
set $path_info $2;
}
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_FILENAME $document_root2$fastcgi_script_name2;
将
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
修改为
fastcgi_param SCRIPT_NAME $fastcgi_script_name2;
关于ThinkPHP在Nginx服务器下出错的解决方法
内容版权声明:除非注明,否则皆为本站原创文章。