排查 Apache 报错日志,一般按下面思路来,从看日志 → 定位错误 → 查配置/权限/资源 → 验证修复一步步走。
/var/log/apache2/access.log
/var/log/apache2/error.log
/var/log/httpd/access_log
/var/log/httpd/error_log
如果使用了 ErrorLog:
ErrorLog ${APACHE_LOG_DIR}/example.com_error.log
tail -f /var/log/apache2/error.log
复现问题(刷新页面 / 访问接口),看实时报错。
典型错误:
(13)Permission denied: access to /index.html denied
排查:
ls -l /var/www/html
www-data 或 apache)ps aux | grep apache
getenforce
setenforce 0 # 临时关闭测试
✅ 修复示例:
chown -R www-data:www-data /var/www/html
chmod -R 755 /var/www/html
常见原因:
index 文件<Directory> 配置禁止访问检查:
<Directory /var/www/html>
Require all granted
</Directory>
apachectl -S
通常是:
看错误日志重点:
PHP Fatal error
测试 .htaccess:
mv .htaccess .htaccess.bak
AH00526: Syntax error
检查配置:
apachectl configtest
Address already in use: AH00072
ss -lntp | grep :80
LogLevel alert trap core
# 或
LogLevel debug
改完重启:
systemctl restart apache2
apachectl configtest 是否 OK如果你愿意,可以把 具体的报错内容贴出来,我可以直接帮你判断是哪种问题、怎么改。