/var/log/httpd/error_log
/var/log/nginx/error.log
、/var/log/php-fpm/error.log
/var/log/php-fpm/error.log
或 /run/php-fpm/www-error.log
php --ini
找到 php.ini
,检查 error_log
路径。tail -f error_log
grep "error" error_log
grep "PHP Fatal error" error_log | awk '{print $1, $2, $3, $4, $5}' | sort | uniq -c | sort -nr
file
插件采集日志,Kibana 创建仪表盘展示错误趋势。goaccess /var/log/httpd/access_log -o report.html
。logrotate
定期压缩旧日志,避免占用磁盘空间。/etc/logrotate.d/php-fpm
,设置每日轮转并保留 10 个备份。error_reporting
和 log_errors
配置记录详细错误(如语法错误、数据库连接失败)。fail2ban
防御。