zoukankan      html  css  js  c++  java
  • 关于ThinkPHP在Nginx服务器下因PATH_INFO出错的解决方法

    参考:https://www.linuxidc.com/Linux/2011-11/46871.htm

    这是一个ningx设置的问题,和TP无关。TP默认使用PATH_INFO来做CURD,而nginx默认设置不处理PATH_INFO,查看nginx可以看到出错日志:
    2010/01/09 22:05:36 [error] 13988#9380: *3 CreateFile() "E:companyhomelabsphp hinkphpserver ginx-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_name2linux

  • 相关阅读:
    Linux 实战
    bash 环境配置及脚本
    Linux vi/vim
    Linux 正则表达式
    001 KNN分类 最邻近算法
    测序名解
    流式细胞术
    CircRNA 环化RNA
    笔记总结
    Flume
  • 原文地址:https://www.cnblogs.com/iitrust/p/12332999.html
Copyright © 2011-2022 走看看