美文网首页
ThinkPHP部署nginx时出现Access denied

ThinkPHP部署nginx时出现Access denied

作者: 蟠龙有悔 | 来源:发表于2020-08-19 18:34 被阅读0次

原来只想在域名conf中加上路由重定向

location / {
    index  index.php index.html index.htm;
    if (!-e $request_filename) {
      rewrite  ^/(.*)$  /index.php?s=$1  last;
      break;
    }
}

但是请求地址出现了 Access denied,各种操作后得出比较精简的配置如下:

  1. 修改 /usr/local/php/etc/php.ini
#cgi.fix_pathinfo由0改为1
  1. 修改 域名conf
location ~ [^/]\.php(/|$) {
    fastcgi_pass unix:/dev/shm/php-cgi.sock;
    fastcgi_index index.php;
    #添加TP5的三个配置
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_param   PATH_INFO   $fastcgi_path_info;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }

如果只添加TP5的三个配置(主要是 fastcgi_split_path_info ^(.+\.php)(/.+)$;),请求网址出现循环请求的bug,吓死叔叔了

摘录:解决ThinkPHP部署nginx时出现Access denied.

相关文章

网友评论

      本文标题:ThinkPHP部署nginx时出现Access denied

      本文链接:https://www.haomeiwen.com/subject/laedjktx.html