在 Debian 系统上,Apache(通常是 Apache2)的日志主要有以下几个核心用途,简单说就是:记录谁访问了、访问了什么、出了什么错。
在 Debian 中,Apache 日志一般在:
/var/log/apache2/access.log/var/log/apache2/error.log(也可能按虚拟主机分目录,如 other_vhosts_access.log)
记录每一次 HTTP 请求,例如:
用途:
记录 Apache 运行中的错误和警告,例如:
用途:
通过日志可以:
200 正常301/302 重定向403 禁止访问(权限问题)404 页面不存在500 服务器内部错误503 服务不可用# 实时查看错误日志
tail -f /var/log/apache2/error.log
# 查看访问日志最后 100 行
tail -n 100 /var/log/apache2/access.log
# 统计访问最多的 IP
awk '{print $1}' access.log | sort | uniq -c | sort -nr | head
Apache 日志是用来“看见服务器发生了什么”的,是排错、安全、运维和分析的基础。
如果你愿意,我也可以帮你: