CentOS 上 Apache(httpd)宕机(停止响应 / 进程退出)的原因很多,下面按常见程度和排查思路给你一个系统性的说明。
现象
排查
dmesg | grep -i kill
或
grep -i oom /var/log/messages
常见原因
现象
排查
httpd -t
# 或
apachectl configtest
现象
server reached MaxRequestWorkers setting
查看
httpd -V | grep MPM
(常见为 prefork / worker / event)
解决
MaxRequestWorkers现象
检查
df -h
重点目录
/var/log/tmp/var/www现象
检查
df -i
现象
code=killed, status=9
查看
journalctl -u httpd
可能原因
表现
排查
netstat -an | grep :80 | wc -l
# 1. 服务状态
systemctl status httpd
# 2. 错误日志
tail -n 100 /var/log/httpd/error_log
# 3. 系统日志
journalctl -u httpd
# 4. 内存
free -h
dmesg | grep -i oom
# 5. 磁盘
df -h
df -i
# 6. 配置
httpd -t
你可以补充:
我可以直接帮你定位是哪一类问题。