在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]。