php-fpm不输出php错误日志
使用如下php的配置
php-fpm.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
[global] pid = /usr/local/php/var/run/php-fpm.pid error_log = /usr/local/php/var/log/php-fpm.log log_level = notice [www] listen = /tmp/php-cgi.sock listen.backlog = -1 listen.allowed_clients = 127.0.0.1 listen.owner = www listen.group = www listen.mode = 0666 user = www group = www pm = dynamic pm.max_children = 20 pm.start_servers = 10 pm.min_spare_servers = 10 pm.max_spare_servers = 20 request_terminate_timeout = 100 request_slowlog_timeout = 5 slowlog = var/log/slow.log catch_workers_output = 1 php_flag[display_errors] = off php_admin_value[error_log] = var/log/fpm-php.www.log php_admin_flag[log_errors] = on php_admin_value[memory_limit] = 32M |
php.ini
1 2 3 4 5 |
[PHP] error_reporting = E_ALL & ~E_NOTICE display_errors = Off log_errors = On error_log = "/usr/local/php/var/log/error_log" |
当通过浏览器访问系统发生500错误时,不记录错误日志内容,通过使用php在命令行直接执行php脚本却可以生成错误日至到日志文件。
说明php的配置正确,后台能够生成日志,问题应该出在php脚本自身上。
查询源码后发现php中有error_reporting(0);屏蔽了所有错误。
修改成error_reporting(E_ALL);可以生成错误信息到日志文件了。