通過FastCGI運行的PHP,在用戶會見時呈現(xiàn)錯誤,會首先寫入到PHP的errorlog中假如PHP的errorlog無法寫入,則會將錯誤內(nèi)容返回給FastCGI接口,然后nginx在收到FastCGI的錯誤返回跋文錄到了nginx的errorlog中
所以將php的錯誤輸出到nginx的error_log中的步伐:
1.修改php-fpm.conf中設置,沒有則增加
catch_workers_output = yes
;error_log = log/error_log
2.修改php.ini中設置,韓國百兆不限流主機
新加坡服務器,沒有則增加
;display_errors = off //不顯示錯誤信息(不輸出到頁面或屏幕上)
log_errors = On
;error_log = “/usr/local/lnmp/php/var/log/error_log”
error_reporting=E_ALL&~E_NOTICE
注:
php-fpm.conf中的php_admin_value[error_log],php_admin_flag[log_errors]參數(shù)會包圍到php.ini的error_log,log_errors中
假如只想輸出到php-fpm的error_log中,則在php-fpm.conf或php.ini中任意設置一個error_log目次,并擔保該目次存在。
假如想要輸出到nginx的error_log中,則必需去掉這兩個參數(shù),然后再nginx中設置error_log參數(shù)。