在頁面中使用gzip可以有效的減低頁面的大小,加快網(wǎng)頁的下載速度。在lighttpd中對php頁面進行壓縮,需要兩個步驟:
1. 編輯 lighttpd.conf
將 “mod_compress” 設(shè)為啟用
接著找到
## compress module
在下面加入
compress.cache-dir = “/var/tmp/lighttpd/cache/”
compress.filetype = (”text/plain”, “text/html”, “text/css”, “text/javascript”)
compress.filetype = (”text/plain”, “text/html”, “text/css”, “text/javascript”)
做完上面的動作后,
基本上 .txt .html .css .js 的文件都會被Gzip壓縮了。但php此時還沒有壓縮
對于動態(tài)的php文件,還需要在php.ini中做相關(guān)設(shè)置,否則.php頁面還是不使用壓縮模式
2. 編輯 php.ini
修改
zlib.output_compression = On
zlib.output_handler = On
重新啟動Lighttpd。
這樣php也壓縮了