在Ubuntu上优化Apache响应时间可从以下方面入手:
event(高并发)或worker(多线程),禁用prefork。mod_deflate:压缩响应内容,减少传输时间。mod_expires:设置缓存过期时间,减少重复请求。KeepAlive并设置KeepAliveTimeout(建议2-5秒)和MaxKeepAliveRequests(如100)。MaxRequestWorkers(根据服务器资源)和MaxConnectionsPerChild(防止内存泄漏)。mod_cache缓存静态资源(如图片、CSS)。CacheRoot和缓存目录层级。修改配置后需重启Apache服务:sudo systemctl restart apache2[1,2,3,5,6,7,8,9,10,11]。