PHP出现access denied问题及解决办法
配置好PHP环境后,访问页面,页面上只出现了 Access denied字样。
问题分析
打开 /usr/local/php/etc/php.ini 文件,找到 cgi.fix_pathinfo
; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's ; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok ; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting ; this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting ; of zero causes PHP to behave as before. Default is 1. You should fix your scripts ; to use SCRIPT_FILENAME rather than PATH_TRANSLATED. ; http://php.net/cgi.fix-pathinfo cgi.fix_pathinfo=0
这里注释里默认是1,但是用 oneinstack 安装后默认是0。
如果在Nginx里配置了
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
则 cgi.fix_pathinfo=0 必须改为1。
解决
配置修改为 cgi.fix_pathinfo=1,重启 php-fpm 和 Nginx 后解决。