ThinkPHP部署nginx时出现Access denied

2020-08-19  本文已影响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.

上一篇 下一篇

猜你喜欢

热点阅读