linux apache gzip filters,Linux Apache2如何开启gzip (deflate module) 压缩功能
檢查你的網站是否啟用了gzip,用chrome打開網站比如http://www.techbrood.com
選中一個請求,查看Response header部分,如果沒有包含
Content-Encoding: gzip
那么你還沒有開啟gzip網頁壓縮功能。
1.首先檢查是否已安裝mod_deflate:
# /usr/local/apache2/bin/apachectl -t -D DUMP_MODULES
Loaded Modules:
...
deflate_module (static)
...
Syntax OK
如果沒有deflate模塊,則需要重新編譯apache2.
首先查看你apache2安裝路徑build目錄下的config.nice文件,其中有原來的configure(編譯選項)
然后添加 ./configure ...... --enable-deflate,重新make && make install。重啟apache。
或者使用apxs:
1. 查找模塊deflate
find your_httpd2_download_folder?-name mod_deflate.c
cd your_httpd2_download_folder/modules/filters
2. 安裝mod_deflate
/usr/local/apache2/bin/apxs??-i -c -a mod_deflate.c
3. 配置mod_deflate
vi /usr/local/apache2/conf/httpd.conf
LoadModule deflate_module ????modules/mod_deflate.so
2.在配置中開啟gzip
在httpd配置文件中添加如下語句(注意,這里使用了apache2里面的mod_deflate而不是1.3里面的mod_gzip):
AddType?application/x-javascript?.js
AddType?text/css?.css
AddOutputFilterByType?DEFLATE?text/css?application/x-javascript?text/x-component?text/html?text/richtext?image/svg+xml?text/plain?text/xsd?text/xsl?text/xml?image/x-icon?application/javascript
BrowserMatch?^Mozilla/4?gzip-only-text/html
BrowserMatch?^Mozilla/4\.0[678]?no-gzip
BrowserMatch?\bMSIE?!no-gzip?!gzip-only-text/html
Header?append?Vary?User-Agent?env=!dont-vary
如果要對某個特定類型的文件進行壓縮,可以先AddType text/svg .svg, 然后把text/svg添加到AddOutputFilterByType列表中.
最后重啟apache:
service httpd restart
即可生效。
總結
以上是生活随笔為你收集整理的linux apache gzip filters,Linux Apache2如何开启gzip (deflate module) 压缩功能的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux 进程装入 物理内存 页表,l
- 下一篇: linux sit0 wifi,I.MX