远程协助
当前位置:重庆拓磊计算机运营维护中心 > 文档中心 > 服务器 >
标题:Linux下配置apache模块:gzip压缩和expires缓存设置_Web服务器教程重庆网络维护    日期:2020-01-02
/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

重庆综合布线网络工程服务重庆IT维护
下一篇:IIS服务器下做301永久重定向设置方法_Web服务器教程虚拟化存储

联系我们
  • 客服热线:023-63522929(7 x 24h)
  • 在线客服:
  • 微信公众号 官方微博