在 CentOS 上排查 Apache(httpd)日志报错,通常按下面几步来:
systemctl status httpd
或
service httpd status
看是否 running,以及有没有直接报错。
CentOS 默认路径一般是:
/var/log/httpd/error_log
实时查看最新报错:
tail -f /var/log/httpd/error_log
或看最近 100 行:
tail -n 100 /var/log/httpd/error_log
/var/log/httpd/access_log
tail -n 100 /var/log/httpd/access_log
查看 Apache 配置:
grep -R "ErrorLog" /etc/httpd/
或
httpd -S
(13)Permission denied: access to /index.html denied
检查:
ls -l /var/www/html
getenforce # 看 SELinux
如果是 Enforcing:
setenforce 0 # 临时关闭
或修复上下文:
restorecon -Rv /var/www
(98)Address already in use: AH00072
说明端口被占:
netstat -tunlp | grep :80
httpd -t
或
apachectl configtest
Cannot load modules/mod_xxx.so
检查模块是否安装、路径是否正确。
编辑:
/etc/httpd/conf/httpd.conf
设置:
LogLevel alert trap
或 debug(排错用):
LogLevel debug
重启:
systemctl restart httpd
如果你方便,可以直接把 error_log 里的具体报错内容 发出来,我可以帮你精确判断原因。