php的错误输出到nginx的日志中

https://www.mfisp.com/html/help/server/20170623/7901.html

通过FastCGI运行的PHP,在用户会见时呈现错误,会首先写入到PHP的errorlog中假如PHP的errorlog无法写入,则会将错误内容返回给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]参数会包围到php.ini的error_log,log_errors中
假如只想输出到php-fpm的error_log中,则在php-fpm.conf或php.ini中任意设置一个error_log目次,并担保该目次存在。
假如想要输出到nginx的error_log中,则必需去掉这两个参数,然后再nginx中设置error_log参数。

 
原文地址:https://www.cnblogs.com/musings/p/13275500.html