以下是CentOS Apache2性能调优的关键技巧:
MaxKeepAliveRequests(如100)和KeepAliveTimeout(如5秒)。worker或event模块(默认prefork适合无线程安全模块场景),优化StartServers、MaxRequestWorkers等参数。mod_expires设置缓存时间(如CSS/JS缓存30天)。mod_deflate压缩文本类数据(如HTML/CSS/JS)。/etc/sysctl.conf,优化TCP连接(如net.ipv4.tcp_tw_reuse=1)、文件句柄数等。/etc/security/limits.conf,提升nofile值(如65535)。mod_rewrite若未使用),减少资源占用。LogLevel warn)。mod_proxy和mod_cache缓存后端响应,减轻服务器压力。mod_http2提升多路复用性能(需客户端支持)。mod_proxy_balancer分发请求到多个Apache实例。注意:修改配置后需重启Apache服务(systemctl restart httpd),并使用top、ab等工具监控性能,确保优化效果。