CentOS 上 Apache(通常是 httpd)启动失败的原因有很多,下面按最常见 → 不常见帮你梳理,并给出排查方法。
现象
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
排查
ss -lntp | grep ':80'
# 或
netstat -lntp | grep ':80'
常见占用者
解决
现象
快速验证
getenforce
# Enforcing → 很可能有关
临时关闭测试
setenforce 0
systemctl start httpd
正式解决
setsebool -P httpd_can_network_connect 1
# 或修复上下文
restorecon -Rv /var/www
现象
Job for httpd.service failed because the control process exited with error code
必做一步(非常重要)
httpd -t
# 或
apachectl configtest
根据报错改配置。
Apache 实际启动了,但访问不了。
firewall-cmd --list-all
放行:
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload
现象
Permission denied: [client] AH00035
检查
ls -ld /var/www/html
解决
755644请直接看这两个地方:
journalctl -xe
journalctl -u httpd
Apache 错误日志:
tail -n 50 /var/log/httpd/error_log
你可以一条条对照:
httpd -t 是否 OK请把下面信息贴出来(直接复制即可):
systemctl status httpd
journalctl -xe | tail -n 30
httpd -t
我可以直接告诉你具体是哪一行配置或系统问题。