声明:配置时候用编辑来查看,因为有些内容,预览时显示不
出来!!!
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 指定所需压缩的文件 ########可有可无
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
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
9、/etc/init.d/apachectl restart
阅读(2607) | 评论(0) | 转发(0) |