在 CentOS 上实时监控 Apache 日志,常见且实用的方法有以下几种,按使用频率从高到低说明:
tail -f /var/log/httpd/access_log
tail -f /var/log/httpd/error_log
按
Ctrl + C退出
✅ 适合:快速排查问题、看实时请求
tail -f /var/log/httpd/access_log /var/log/httpd/error_log
yum install -y epel-release
yum install -y multitail
multitail /var/log/httpd/access_log /var/log/httpd/error_log
✅ 优点:
less +F /var/log/httpd/access_log
Ctrl + C 停止滚动F 继续实时跟踪✅ 适合:边看边搜索
yum install -y httpd-tools
watch -n 1 "apachectl status"
或访问:
http://服务器IP/server-status
(需在 httpd.conf 中开启 mod_status)
yum install -y goaccess
goaccess /var/log/httpd/access_log -o /var/www/html/report.html --log-format=COMBINED
浏览器打开 report.html 即可看实时统计
yum install -y lnav
lnav /var/log/httpd/
✅ 自动识别日志格式、高亮、搜索
| 类型 | 路径 |
|---|---|
| 访问日志 | /var/log/httpd/access_log |
| 错误日志 | /var/log/httpd/error_log |
| 自定义虚拟主机 | 看 httpd.conf 或 conf.d/*.conf |
tail -fmultitailgoaccess如果你告诉我:
我可以给你更精准的方案。