Ubuntu 上 Apache2 卡顿 的原因通常可以归为几大类:资源不足、配置不当、模块问题、或外部依赖慢。下面按常见程度给你一个排查清单。
top
htop
free -h
✅ 解决:
MaxClients / MaxRequestWorkers查看:
apache2ctl -M | grep mpm
常见模式:
mpm_prefork(默认,最吃内存)mpm_event(推荐)编辑:
/etc/apache2/mods-enabled/mpm_prefork.conf
示例(小服务器):
<IfModule mpm_prefork_module>
StartServers 2
MinSpareServers 2
MaxSpareServers 5
MaxRequestWorkers 50
MaxConnectionsPerChild 1000
</IfModule>
✅ 建议:
mpm_event + php-fpmtail -f /var/log/apache2/error.log
常见原因:
✅ 优化:
php-fpmiostat -x 1
%util✅ 解决:
du -sh /var/log/apache2
✅ 解决:
logrotate --force /etc/logrotate.d/apache2
apache2ctl -M
禁用:
a2dismod status
a2dismod autoindex
netstat -ant | wc -l
✅ 解决:
ulimit, tcp)free -h
top
apache2ctl -S
tail -n 50 /var/log/apache2/error.log
如果你愿意,可以告诉我:
我可以帮你精准定位并给一份配置文件示例。