声明:配置时候用编辑来查看,因为有些内容,预览时显示不出来。
1、vi /usr/local/apache2/bin/apr-1-config
2、改 LDFLAGS="" 为 LDFLAGS="-lz"
3、保存退出
4、 /usr/local/apache2/bin/apxs -i -a -c /usr/local/src/httpd-2.2.9/modules/filters/mod_deflate.c
5、查看配置文件,已经加载了模块“LoadModule deflate_module modules/mod_deflate.so”
6、/usr/local/apache2/bin/apxs -i -a -c /usr/local/src/httpd-2.2.9/modules/metadata/mod_expires.c
7、 /usr/local/apache2/bin/apxs -i -a -c /usr/local/src/httpd-2.2.9/modules/metadata/mod_headers.c
8、vim /usr/local/apache2/conf/httpd.conf
在“LoadModule expires_module modules/mod_expires.so ”添加:
DeflateCompressionLevel 3 指定压缩比######### 可有可无
AddOutputFilter DEFLATE html xml php js css 指定所需压缩的文件 ########可有可无
<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>
9、重新启动
/etc/init.d/apachectl restart
您可能感兴趣的文章:
1.Apache开启gzip压缩模块
2.(图文介绍)apache2中开启gzip压缩
3.安装mod_deflate模块启用apache的GZIP压缩
4.教你修改apache配置文件开启gzip压缩传输
5.apache启用gzip压缩方法
6.apache启用gzip压缩以提升性能
7.apache开启gzip配置
8.教你如何配置Apache的Gzip模块