在 CentOS 上,Apache(通常是 httpd)的日志默认位置在:
/var/log/httpd/access_log/var/log/httpd/error_log下面按常见需求给你一些实用命令示例。
cat /var/log/httpd/error_log
或实时查看:
tail -f /var/log/httpd/error_log
cat /var/log/httpd/access_log
实时查看:
tail -f /var/log/httpd/access_log
tail -n 100 /var/log/httpd/error_log
grep "error" /var/log/httpd/error_log
grep "500" /var/log/httpd/access_log
grep "192.168.1.100" /var/log/httpd/access_log
awk '{print $1}' /var/log/httpd/access_log | sort | uniq -c | sort -nr | head
grep " 404 " /var/log/httpd/access_log
sed -n '/10\/Apr\/2025:10:00:00/,/10\/Apr\/2025:11:00:00/p' /var/log/httpd/access_log
journalctl -u httpd
实时查看:
journalctl -u httpd -f
systemctl status httpd
grep ErrorLog /etc/httpd/conf/httpd.conf
grep CustomLog /etc/httpd/conf/httpd.conf
如果你愿意,可以告诉我:
我可以给你更精确的命令。