手机版
你好,游客 登录 注册
背景:
阅读新闻

关于ThinkPHP在Nginx服务器下出错的解决方法

[日期:2011-11-10] 来源:Linux社区  作者:Linux [字体:大 中 小]
这是一个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集成包,就以此为例,www.linuxidc.com 修改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; linux
相关资讯       Nginx 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款