標籤:不能 php-fpm fas var pre apache starting global 重啟
最近在本地搭建的LNMP的開發環境。為了開發的時候不影響前端的正常開發就屏蔽的PHP裡面php.ini中的一些錯誤提示。但是這樣一來,就影響到了後端開發的一些問題比如不能及時調試開發中的一些問題。nginx與apache不一樣,在apache中可以直接指定php的錯誤記錄檔,那樣在php執行中的錯誤資訊就直接輸入到php的錯誤記錄檔中,可以方便查詢。在nginx中事情就變成了這樣:nginx只對頁面的訪問做access記錄日誌。不會有php的error log 資訊。nginx把對php的請求發給php-fpm fastcgi進程來處理,預設的php-fpm只會輸出php-fpm的錯誤資訊,在php-fpm的errors log裡也看不到php的errorlog。原因是php-fpm的設定檔php-fpm.conf中預設是關閉worker進程的錯誤輸出,直接把他們重新導向到/dev/null,所以我們在nginx的error log 和php-fpm的errorlog都看不到php的錯誤記錄檔。所以我們要進行如下的設定就能查看到nginx下php-fpm不記錄php錯誤記錄檔的方法:
1,修改php-fpm.conf中的配置,如果沒有請增加:[global]; Note: the default prefix is /usr/local/php/varerror_log = log/php_error_log[www]catch_workers_output = yes2.修改php.ini中配置,沒有則增加 log_errors = On error_log = "/usr/local/php/var/log/error_log" error_reporting=E_ALL&~E_NOTICE3.重啟php-fpm,當PHP執行錯誤時就能看到錯誤記錄檔在”/usr/local/lnmp/php/var/log/php_error_log”中了如果出現:[[email protected] etc]# service php-fpm restartGracefully shutting down php-fpm . doneStarting php-fpm [17-Apr-2014 18:40:52] ERROR: [/usr/local/php/etc/php-fpm.conf:5] unknown entry ‘catch_workers_[17-Apr-2014 18:40:52] ERROR: failed to load configuration file ‘/usr/local/php/etc/php-fpm.conf‘[17-Apr-2014 18:40:52] ERROR: FPM initialization failed failed那請在第一步的時候,認真將配置寫入相對應的組中,不然就出現上面的:ERROR: [/usr/local/php/etc/php-fpm.conf:5] unknown entry ‘catch_workers_output’
LNMP環境下配置PHP錯誤資訊提示