Apache deflate模块配置说明
2011-12-30 11:17
190 查看
一、 需求
压缩apache的输出内容,降低网站带宽
二、 加载Apache的deflate模块
1、 修改apr-config
vi /usr/local/apache2/bin/apr-config
修改LDFLAGS=" " 为 LDFLAGS="-lz"
2、 到apache源安装目录下,例如
cd /root/httpd-2.0.55/modules/filters
3、加载mod_deflate模块
/usr/local/apache2/bin/apxs -i -a -c mod_deflate.c
如果没有安装headers模块,加载headers模块
cd /root/httpd-2.0.55/modules/metadata
加载mod_headers模块
/usr/local/apache2/bin/apxs -i -a –c mod_headers.c
三、配置Apache主配置文件
1. 在httpd.conf主配置文件里添加如下行
#声明输入流的byte数量
DeflateFilterNote Input instream
#声明输出流的byte数量
DeflateFilterNote Output outstream
#声明压缩的百分比
DeflateFilterNote Ratio ratio
#声明日志类型
LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
CustomLog logs/deflate_log deflate
#指定压缩参数
<Location />
# 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.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpg|cab|jpe?g|exe|bmp|mp3|rar|zip|swf|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Location>
二、日志输出格式如下
[root@trffic2 logs]# tail -f access_log
"GET /apache_pb.gif HTTP/1.1" -/- (-%)
"GET /manual/ HTTP/1.1" 2163/7434 (29%)
"GET /manual/style/css/manual.css HTTP/1.1" 3973/18335 (21%)
"GET /manual/style/css/manual-loose-100pc.css HTTP/1.1" 1006/2882 (34%)
"GET /manual/style/css/manual-print.css HTTP/1.1" 2994/13017 (23%)
压缩apache的输出内容,降低网站带宽
二、 加载Apache的deflate模块
1、 修改apr-config
vi /usr/local/apache2/bin/apr-config
修改LDFLAGS=" " 为 LDFLAGS="-lz"
2、 到apache源安装目录下,例如
cd /root/httpd-2.0.55/modules/filters
3、加载mod_deflate模块
/usr/local/apache2/bin/apxs -i -a -c mod_deflate.c
如果没有安装headers模块,加载headers模块
cd /root/httpd-2.0.55/modules/metadata
加载mod_headers模块
/usr/local/apache2/bin/apxs -i -a –c mod_headers.c
三、配置Apache主配置文件
1. 在httpd.conf主配置文件里添加如下行
#声明输入流的byte数量
DeflateFilterNote Input instream
#声明输出流的byte数量
DeflateFilterNote Output outstream
#声明压缩的百分比
DeflateFilterNote Ratio ratio
#声明日志类型
LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
CustomLog logs/deflate_log deflate
#指定压缩参数
<Location />
# 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.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpg|cab|jpe?g|exe|bmp|mp3|rar|zip|swf|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Location>
二、日志输出格式如下
[root@trffic2 logs]# tail -f access_log
"GET /apache_pb.gif HTTP/1.1" -/- (-%)
"GET /manual/ HTTP/1.1" 2163/7434 (29%)
"GET /manual/style/css/manual.css HTTP/1.1" 3973/18335 (21%)
"GET /manual/style/css/manual-loose-100pc.css HTTP/1.1" 1006/2882 (34%)
"GET /manual/style/css/manual-print.css HTTP/1.1" 2994/13017 (23%)
相关文章推荐
- Apache deflate模块配置说明
- Apache deflate模块配置
- apache之gzip模块或deflate模块的配置信息
- Apache Shiro学习(五)Shiro 配置说明
- Apache自带 ab压测工具 Windows配置使用说明 - 随笔记录
- Apache及Tomcat安装及配置说明
- Apache滚动日志配置及参数说明
- Apache 2.4 For Windows 安装配置说明
- 安装完Apache后,配置httpd.conf来使apache来加载php模块
- Apache使用mod_deflate模块压缩页面优化传输速度
- APACHE默认模块功能说明
- apache 缓存模块配置
- Apache Log4j配置说明
- 自定义模块的配置说明
- apache安装配置说明1
- Apache使用ssl模块配置HTTPS
- ≡ Windows XP + Apache 2.2.4 + PHP 5.2 + MySQL 5.0.18 +eclipse3.2+wampp-2.2.zip+HardCore环境配置说明 ≡
- apache 集群tomcat配置参数说明
- rsyncd - 模块常用配置说明
- Apache Shiro 使用手册(五)Shiro 配置说明