在 CentOS 上“过滤 PHP 日志”通常分几种场景,下面按最常见用法给你说明,基本都能直接用。
CentOS 下 PHP 日志一般在:
php -i | grep error_log
常见路径:
/var/log/php-fpm/error.log
/var/log/php_errors.log
/var/log/php-fpm/error.log
/var/log/php-fpm/www-error.log
/var/log/nginx/error.log
/var/log/httpd/error_log
tail -f /var/log/php-fpm/error.log | grep -i error
tail -f /var/log/php-fpm/error.log | grep "order.php"
tail -f /var/log/php-fpm/error.log | grep -v "Notice"
grep "2026-01-21" /var/log/php-fpm/error.log | grep -i error
grep -E "Fatal error|Warning" /var/log/php-fpm/error.log
awk '$1 >= "2026-01-21" && $1 <= "2026-01-22"' /var/log/php-fpm/error.log
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED
log_errors = On
error_log = /var/log/php_errors.log
重启 PHP:
systemctl restart php-fpm
如果 PHP 日志走 systemd:
journalctl -u php-fpm -f
过滤:
journalctl -u php-fpm | grep error
查看最近 100 条 PHP 错误:
tail -n 100 /var/log/php-fpm/error.log | grep -i error
只看某个 IP 的请求错误(Nginx + PHP):
grep "192.168.1.100" /var/log/nginx/error.log
如果你能告诉我:
我可以直接给你精准命令。