在 Ubuntu 系统中,Apache(通常是 Apache2)的日志默认位置如下:
记录所有访问请求:
/var/log/apache2/access.log
记录错误和服务器运行状态:
/var/log/apache2/error.log
/var/log/apache2/ssl_access.log
/var/log/apache2/你的域名-access.log
/var/log/apache2/你的域名-error.log
# 实时查看错误日志
sudo tail -f /var/log/apache2/error.log
# 查看最近的访问记录
sudo tail -n 50 /var/log/apache2/access.log
如果日志不在默认位置,可检查 Apache 配置:
grep -R "ErrorLog" /etc/apache2/
grep -R "CustomLog" /etc/apache2/
如果你是用 apt 安装的 Apache2,以上路径基本都是默认正确的。