nginx怎么輸出php錯誤日志

nginx輸出php錯誤日志的方法:1、編輯php-fpm.conf配置文件,添加【error_log = log/error_log】;2、編輯php.ini配置文件,添加【log_errors = On】;3、重啟php-fpm。

nginx怎么輸出php錯誤日志

問題分析:

nginx是一個web服務器,因此nginx的access日志只有對訪問頁面的記錄,不會有php 的 error log信息。

(推薦教程:nginx教程

nginx把對php的請求發(fā)給php-fpm fastcgi進程來處理,默認的php-fpm只會輸出php-fpm的錯誤信息,在php-fpm的errors log里也看不到php的errorlog。

立即學習PHP免費學習筆記(深入)”;

原因是php-fpm的配置文件php-fpm.conf中默認是關閉worker進程的錯誤輸出,直接把他們重定向到/dev/null,所以我們在nginx的error log 和php-fpm的errorlog都看不到php的錯誤日志。

解決nginx下php-fpm不記錄php錯誤日志的辦法:

1、修改php-fpm.conf中配置 沒有則增加

catch_workers_output?=?yes error_log?=?log/error_log

2、修改php.ini中配置,沒有則增加

log_errors?=?On error_log?=?"/usr/local/lnmp/php/var/log/error_log" error_reporting=E_ALL&~E_NOTICE

3、重啟php-fpm

當PHP執(zhí)行錯誤時就能看到錯誤日志在”/usr/local/lnmp/php/var/log/error_log”中了。

相關推薦:nginx教程

以上就是

? 版權聲明
THE END
喜歡就支持一下吧
點贊5 分享