Ubuntu下Apache内存优化实操指南
一 基线评估与监控
二 选择合适的MPM并调整关键参数
三 精简模块与系统层面优化
四 快速配置示例 prefork 与 event
<IfModule mpm_prefork_module>
StartServers 2
MinSpareServers 2
MaxSpareServers 5
MaxRequestWorkers 50
MaxConnectionsPerChild 10000
</IfModule>
KeepAlive On
KeepAliveTimeout 5
HostnameLookups Off
<IfModule mpm_event_module>
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxRequestWorkers 150
MaxConnectionsPerChild 10000
</IfModule>
KeepAlive On
KeepAliveTimeout 5
HostnameLookups Off
sudo a2enmod deflate expires cache;sudo apache2ctl configtest && sudo systemctl reload apache2;五 故障排查与长期维护