配置好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 后解決。