Apache 访问日志(通常是 access_log 或 access.log)为空,常见原因有以下几种,你可以按顺序排查:
检查 Apache 配置文件(httpd.conf 或虚拟主机配置):
CustomLog "logs/access_log" common
确认:
✅ 排查:
httpd -S # 查看生效的虚拟主机和日志配置
ls -l /path/to/access_log
可能原因:
✅ 排查:
systemctl status httpd
netstat -tunlp | grep :80
curl http://127.0.0.1
rotatelogs 或管道日志如果配置类似:
CustomLog "|/usr/sbin/rotatelogs logs/access_log 86400" common
日志可能:
✅ 排查:
ls -l logs/
例如:
CustomLog logs/access_log common env=!dontlog
或使用了 SetEnvIf 条件过滤。
✅ 排查:
搜索配置中是否有 env=、SetEnvIf、LogLevel
Apache 运行用户(如 www-data、apache)无写权限。
✅ 排查:
ps aux | grep httpd
ls -ld /path/to/logs
Denied 或 Rewrite 拦截请求在到达日志阶段前被拒绝(如 <Directory> 拒绝、mod_rewrite 死循环)。
✅ 排查:
error_log 是否有内容Allow from all 测试如果你访问的是:
请求可能根本没到 Apache。
curl http://127.0.0.1
tail -f access_log
systemctl restart httpd
如果你愿意,可以把:
发出来,我可以帮你精准定位。