在 CentOS 上实时查看 PHP 日志,常用方法取决于 PHP 运行方式(PHP-FPM / Apache mod_php / CLI) 以及 日志路径配置。
php --ini
或
php -i | grep error_log
常见配置:
log_errors = On
error_log = /var/log/php/php_errors.log
tail -f(最推荐)tail -f /var/log/php/php_errors.log
如果不知道路径,可先搜一下:
find /var/log -name "*php*"
tail -f /var/log/php-fpm/error.log
tail -f /var/log/php-fpm/www-slow.log
grep -R "log" /etc/php-fpm.d/www.conf
常见配置:
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_value[error_log] = /var/log/php/php_errors.log
tail -f /var/log/httpd/error_log
tail -f /var/log/php-fpm/error.log /var/log/httpd/error_log
tail -f /var/log/php/php_errors.log | ccze
安装:
yum install ccze -y
tail -f /var/log/php/php_errors.log | grep -i error
检查:
ls -l /var/log/php/
ps aux | grep php-fpm
setenforce 0 # 临时关闭 SELinux 测试
并确认:
log_errors = On如果你愿意,可以告诉我:
我可以给你精确的日志路径和命令。