在 Debian 上排查 Apache 日志问题,通常可以按下面几个步骤来做。
systemctl status apache2
apache2 -v
如果服务没起来,先看报错信息。
Debian 中 Apache(通常是 Apache2)默认日志路径:
/var/log/apache2/
常见文件:
access.log:访问日志error.log:错误日志(最重要)other_vhosts_access.log:虚拟主机访问日志(如果启用)查看错误日志:
tail -f /var/log/apache2/error.log
/etc/apache2/apache2.conf
/etc/apache2/sites-enabled/
检查是否有:
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
如果路径不对或被注释,日志可能不会生成。
默认是:
LogLevel warn
排错时可临时调高:
LogLevel debug
然后重启:
systemctl restart apache2
ls -l /var/log/apache2/
Apache 用户通常是 www-data:
ps aux | grep apache2
如果权限不对:
chown -R www-data:adm /var/log/apache2
chmod 750 /var/log/apache2
df -h
df -i
error.log 中看 client denied 或 File does not existDocumentRoot 和目录权限error.log 中 PHP / 配置错误tail -f /var/log/apache2/error.log
apache2ctl -S
确认:
apache2ctl configtest
有错误会直接提示。
Debian 默认用 logrotate:
cat /etc/logrotate.d/apache2
如果日志不滚动:
logrotate -d /etc/logrotate.d/apache2
如果你愿意,可以把:
error.log 的相关报错贴出来,我可以帮你更精确定位问题。