nginx php空白頁 fastcgi_param
今天(tiān)安裝完nginx 後 發現(xiàn)html頁麵(miàn)能正常瀏(liú)覽 但是php文件的頁麵打(dǎ)開後(hòu)是一篇空白 看php-fpm日誌 看nginx日誌都沒找到(dào)問題
上網搜索了半天終於解決了,在這做個記錄備忘
網(wǎng)上的一種說法是缺少這麽(me)一句話(huà)在nginx的配置文件裏
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
這句(jù)話是幹嘛的呢 其實他(tā)就是定義php中用到的服務器變量 也就是$_SERVER
http://wiki.nginx.org/NginxHttpFcgiModule 這個網址下有這麽一(yī)句話
This module allows Nginx to interact with FastCGI processes and control what parameters are passed to the process。
其實也就是服務器像你的處理php的cgi傳遞過(guò)去他需要的一些參數,而至少要有下麵的兩個參數php才能執(zhí)行起來
Below is an example of the minimally necessary parameters for PHP:
fastcgi_param SCRIPT_FILENAME /home/www/scripts/php$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
Parameter SCRIPT_FILENAME is used by PHP for determining the name of script to execute, and QUERY_STRING contains the parameters of the request.
所以 我們在沒(méi)有定義SCRIPT_FILENAME這(zhè)個係統變量的時候 php是沒法解釋執行的
這個變量的定(dìng)義可以寫在nginx的配置文(wén)件nginx.conf裏 也可以寫在外部(bù) 用include的方式在nginx.conf裏包含進來。
關鍵詞:nginx,php空白頁
閱讀本文後您有什麽感想? 已有 人給出評價!
- 0
- 0
- 0
- 0
- 0
- 0