Nginx PHP 返回200,但是空白頁(yè)
ngxin;php-fpm安裝后,html靜態(tài)頁(yè)面沒(méi)問(wèn)題,但是phpinfo頁(yè)面雖然返回200,但總是空白頁(yè)
也沒(méi)有任何報(bào)錯(cuò),考慮應(yīng)該是nginx已經(jīng)將php頁(yè)面轉(zhuǎn)移給php處理了,所以問(wèn)題應(yīng)該在php的配置上,經(jīng)過(guò)查找,發(fā)現(xiàn)需要在nginx中加入一句話
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
安裝完nginx后默認(rèn)的fastcgi_params配置文件中沒(méi)有上面這句話。
在nginx.conf中的
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
或者在fastcgi_params配置文件中加入
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
然后重啟nginx就可以顯示出頁(yè)面了。
關(guān)鍵詞:Nginx,PHP
閱讀本文后您有什么感想? 已有 人給出評(píng)價(jià)!
- 0
- 0
- 0
- 0
- 0
- 0