CentOS 上 Apache(通常是 httpd)启动失败的原因有很多,下面按最常见原因 → 排查方法给你一个系统性的排查思路。
不要只看 “failed”,要看具体原因:
systemctl status httpd -l
journalctl -xe
或直接测试启动:
httpd -t
如果是
Syntax error,说明是配置文件问题。
错误示例
Address already in use: AH00072: make_sock: could not bind to address [::]:80
排查
ss -lntp | grep ':80'
常见占用程序:
解决
错误示例
Permission denied: AH00091: httpd: could not open error log file
排查
getenforce
如果是 Enforcing:
临时测试
setenforce 0
systemctl restart httpd
长期解决(推荐)
semanage port -a -t http_port_t -p tcp 80
restorecon -Rv /var/www
firewall-cmd --list-all
放行:
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload
httpd -t
常见错误:
>VirtualHost 写错Apache 用户一般是 apache
chown -R apache:apache /var/www/html
chmod -R 755 /var/www
例如:
mod_ssl查看:
httpd -M
df -h
df -i
httpd -t
systemctl status httpd
journalctl -xe
ss -lntp | grep 80
getenforce
你可以直接把下面内容贴出来,我可以精准定位:
systemctl status httpd -l
journalctl -xe | tail -30
告诉我:
我可以一步步帮你修。