查看 Apache 日志通常使用 Linux 下的基础命令即可。下面按常见场景给你说明。
/var/log/httpd/access_log
/var/log/httpd/error_log
/var/log/apache2/access.log
/var/log/apache2/error.log
grep -R "CustomLog" /etc/httpd/ # CentOS
grep -R "CustomLog" /etc/apache2/ # Ubuntu
tail -f /var/log/httpd/access_log
# 或
tail -f /var/log/apache2/access.log
tail -f /var/log/httpd/error_log
Ctrl + C退出
tail -n 100 /var/log/httpd/access_log
grep "192.168.1.100" /var/log/httpd/access_log
grep " 404 " /var/log/httpd/access_log
grep "10/Apr/2024:14:" /var/log/httpd/access_log
awk '{print $1}' access_log | sort | uniq -c | sort -nr | head
awk '{print $7}' access_log | sort | uniq -c | sort -nr | head
awk '{print $9}' access_log | sort | uniq -c | sort -nr
ls -l --time-style=full-iso /var/log/httpd/
如果你愿意,可以告诉我:
我可以直接给你一条最合适你的命令。