CentOS 上 Apache 错误排查步骤
一 快速定位
二 常见错误与修复
三 日志与配置定位技巧
四 高频场景速查表
| 症状 | 优先命令 | 处理要点 |
|---|---|---|
| 服务起不来 | systemctl status httpd -l --no-pager;tail -f /var/log/httpd/error_log | 先看日志末几行定位错误类型 |
| 启动报端口占用 | ss -tulpen | grep -E ':80 |
| 配置改完仍报错 | apachectl configtest | 按提示修复语法,再重启 |
| 外部访问不了 | firewall-cmd --list-all | 放行 http/https 并重载防火墙 |
| 访问被拒绝 | ls -ld /var/www/html;getenforce | 校正属主为 apache:apache、权限 755;SELinux 临时置 permissive 验证 |
| 页面不存在 | tail -f /var/log/httpd/error_log | 核对 DocumentRoot 与文件路径是否存在 |
五 修复后验证与建议