Linux下配置apache模块:gzip压缩和expires缓存设置_Web服务器教程

编辑Tag赚U币
/usr/local/apache111/bin/apxs -i -c /home/software/bak/httpd-2.2.3/modules/metadata/mod_expires.c
/usr/local/apache111/bin/apxs -i -c /home/software/bak/httpd-2.2.3/modules/metadata/mod_headers.c


vi /usr/local/apache111/bin/apr-1-config
改 LDFLAGS="" 为 LDFLAGS="-lz"
/usr/local/apache111/bin/apxs -i -c /home/software/bak/httpd-2.2.3/modules/filters/mod_deflate.c


httpd.conf配置:
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so
LoadModule expires_module modules/mod_expires.so

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault A604800
    ExpiresByType text/css M259200
    ExpiresByType application/x-javascript M300
    ExpiresByType image/gif "access plus 2 month"
    ExpiresByType image/jpeg "access plus 2 month"
    ExpiresByType image/png "access plus 2 month"
    ExpiresByType image/x-icon "access plus 2 month"
    ExpiresByType application/x-shockwave-flash A2592000
</IfModule>
<IfModule mod_deflate.c>
    SetOutputFilter DEFLATE

#    DeflateFilterNote Input instream
#    DeflateFilterNote Output outstream
#    DeflateFilterNote Ratio ratio

    LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
    CustomLog logs/deflate_log deflate

    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|mov|avi|mp3|mp4|rm)$ no-gzip dont-vary

    AddOutputFilterByType DEFLATE text/*
    AddOutputFilterByType DEFLATE application/ms* application/vnd* application/postscript application/javascript application/x-javascript
    AddOutputFilterByType DEFLATE application/x-httpd-php application/x-httpd-fastphp

    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4.0[678] no-gzip
    BrowserMatch bMSIE !no-gzip !gzip-only-text/html
</IfModule>

/usr/local/apache111/bin/apachectl -t

来源:网络搜集//所属分类:Web服务器教程/更新时间:2011-12-08
相关Web服务器教程