時間:2015-06-28 00:00:00 來源:IT貓撲網(wǎng) 作者:網(wǎng)管聯(lián)盟 我要評論(0)
首先查看apache是否加載了mod_deflate.so模塊,如果沒有需要安裝加載。找到并下載和當(dāng)前apache版本相同的源碼文件,解壓縮到/home目錄下,在apache安裝目錄下執(zhí)行:
/usr/local/apache2/bin/apxs -i -c /home/httpd-2.0.63/modules/filters/mod_deflate. |
會自動在 httpd.conf添加
LoadModule deflate_module modules/mod_deflate.so |
添加如下設(shè)置:
#Insert filter SetOutputFilter DEFLATE # Netscape 4.x has some problems… BrowserMatch ^Mozilla/4 gzip-only-text/html # Netscape 4.06-4.08 have some more problems BrowserMatch ^Mozilla/4\.0[678] no-gzip # MSIE masquerades as Netscape, but it is fine # BrowserMatch \bMSIE !no-gzip !gzip-only-text/html # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.59 # the above regex won’t work. You can use the following # workaround to get the desired effect: # BrowserMatch \bMSIE !no-gzip !gzip-only-text/html force-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html # Don’t compress images and other SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary SetEnvIfNoCase Request_URI .(?:pdf|doc)$ no-gzip dont-vary AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css AddOutputFilterByType DEFLATE application/x-javascript # Make sure proxies don’t deliver the wrong content Header append Vary User-Agent env=!dont-vary #DeflateFilterNote ratio ratio_info #LogFormat '"%v %h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" (%{ratio}n)' deflate #CustomLog logs/deflate_log deflate |
停止apache服務(wù)./apachectl stop,報錯如下:
Cannot load /usr/local/apache2/modules/mod_deflate.so into server: /usr/local/apache2/modules/mod_deflate.so: undefined symbol: deflate |
解決如下:
vi /usr/local/apache2/bin/apr-config 修改LDFLAGS=" " 為 LDFLAGS="-lz" |
停止啟動服務(wù):仍提示:
DeflateFilterNote not allowed here CustomLog not allowed here |
注釋掉后,正常。
關(guān)鍵詞標(biāo)簽:apache性能優(yōu)化,gzip壓
相關(guān)閱讀
熱門文章 ISAPI Rewrite實現(xiàn)IIS圖片防盜鏈 IIS6.0下配置MySQL+PHP5+Zend+phpMyAdmin 在Windows服務(wù)器上快速架設(shè)視頻編解碼器全攻略 win2000server IIS和tomcat5多站點配置
人氣排行 XAMPP配置出現(xiàn)403錯誤“Access forbidden!”的解決辦法 WIN2003 IIS6.0+PHP+ASP+MYSQL優(yōu)化配置 訪問網(wǎng)站403錯誤 Forbidden解決方法 如何從最大用戶并發(fā)數(shù)推算出系統(tǒng)最大用戶數(shù) Server Application Unavailable的解決辦法 報錯“HTTP/1.1 400 Bad Request”的處理方法 Windows Server 2003的Web接口 http 500內(nèi)部服務(wù)器錯誤的解決辦法(windows xp + IIS5.0)