采用mod_gzip加速Zope和Apache
我们知道 mod_gzip 是用来在服务器端把客户请求的内容压缩后发送给客户端的一个 Apache 模块。本站的 Zope 通过 FastCGI 来实现和 Apache 的结合,Apache 是解析 HTML 页面的服务程序。安装好 mod_gzip 后就即能压缩普通静态页面也能压缩 Zope 文档。
一、安装
http://www.hyperspacecommunications.com/products/mod_gzip.html
页面上有 mod_gzip 的二进制码版本和源码下载。如果你使用前者的话,直接把文件拷贝到 Apache Home 的 libexec 目录下就可以了。下载 mod_gzip.c 后,如果你的 Apache 用 DSO 模式安装的话,用下面简单的命令就可以安装了:
# /www/bin/apxs -i -a -c mod_gzip.c
二、配置
安装完毕以后把下列配置加入 httpd.conf :
# mod_gzip 配置
LoadModule gzip_module libexec/mod_gzip.so
AddModule mod_gzip.c
mod_gzip_on Yes
mod_gzip_minimum_file_size 1002
mod_gzip_maximum_file_size 0
mod_gzip_maximum_inmem_size 60000
mod_gzip_item_include mime ""application/x-httpd-php""
mod_gzip_item_include mime ""text/*""
# 压缩 Zope 的内容:
mod_gzip_item_include file ""[^.]*$""
mod_gzip_item_include mime ""httpd/unix-directory""
mod_gzip_dechunk Yes
mod_gzip_temp_dir ""/tmp""
mod_gzip_keep_workfiles No
mod_gzip_item_include file "".php$""
mod_gzip_item_include file "".txt$""
mod_gzip_item_include file "".html$""
mod_gzip_item_exclude file "".css$""
mod_gzip_item_exclude file "".js$""
并添加下面的行:
LogFormat ""%h %l %u %t ""%r"" %>s %b ""%{Referer}i"" ""%{User-Agent}i"" mod_gzip: %{mod_gzip_compression_ratio}npct."" mod_gzip
把对应虚拟主机配置中的日志文件参数修改为 mod_gzip
三、压缩效果
这样,我们得到类似以下的日志文件:
61.169.41.13 - - [02/Mar/2002:01:24:29 -0500] ""GET /pipermail/freelamp/2002-March/000026.html HTTP/1.1"" 200 72848 ""http://www.freelamp.com/pipermail/freelamp/2002-March/subject.html"" ""Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461; NetCaptor 6.5.0)"" mod_gzip: 54pct.
61.169.41.13 - - [02/Mar/2002:01:24:52 -0500] ""GET /new/publish/1003233602/index_html HTTP/1.1"" 200 4304 ""http://www.freelamp.com/new/publish/search?subject=Zope&op=articles"" ""Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461; NetCaptor 6.5.0)"" mod_gzip: 65pct.
61.169.41.13 - - [02/Mar/2002:01:24:53 -0500] ""GET /new/publish/global_css HTTP/1.1"" 200 629 ""http://www.freelamp.com/new/publish/1003233602/index_html"" ""Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461; NetCaptor 6.5.0)"" mod_gzip: 73pct.
61.169.41.13 - - [02/Mar/2002:01:24:54 -0500] ""GET /new/publish/Images/sitetitle_img HTTP/1.1"" 304 0 ""http://www.freelamp.com/new/publish/1003233602/index_html"" ""Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461; NetCaptor 6.5.0)"" mod_gzip: 0pct.
61.169.41.13 - - [02/Mar/2002:01:26:21 -0500] ""GET /new/publish/index_html HTTP/1.1"" 200 7317 ""http://www.freelamp.com/new/publish/1003233602/index_html"" ""Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461; NetCaptor 6.5.0)"" mod_gzip: 80pct.
61.169.41.13 - - [02/Mar/2002:01:26:22 -0500] ""GET /new/publish/global_css HTTP/1.1"" 200 629 ""http://www.freelamp.com/new/publish/index_html"" ""Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461; NetCaptor 6.5.0)"" mod_gzip: 73pct.
61.169.41.13 - - [02/Mar/2002:01:26:24 -0500] ""GET /new/publish/TopicImages/Tutorial HTTP/1.1"" 304 0 ""http://www.freelamp.com/new/publish/index_html"" ""Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461; NetCaptor 6.5.0)"" mod_gzip: 0pct.
61.169.41.13 - - [02/Mar/2002:01:26:24 -0500] ""GET /new/publish/LinkImages/jsp001_img HTTP/1.1"" 304 0 ""http://www.freelamp.com/new/publish/index_html"" ""Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461; NetCaptor 6.5.0)"" mod_gzip: 0pct.
我们看到 mod_gzip 已经对 .html 和那些没有点的文件作了压缩,压缩率达到了 70-80%。但是,mod_gzip 对图片文件不作压缩。
四、总结
结合,mod_gzip 和缓冲工具等,我们完全可以使一台配置较低的 PC 有足够的能力处理各种 HTML/CGI 等的请求。
(资源库 www.zyku.net)
您可能感兴趣的文章
- 04-02Apache下.htaccess重写URL 实现http自动跳转https的方
- 08-08Apache 修改上传文件大小限制的方法
- 03-12Apache服务器利用.htaccess重写URL实现http自动跳转ht
- 03-12CentOS系统下Apache开启Rewrite功能
- 11-23linux 下 apache启动、停止、重启命令
- 09-18Docker容器内重启Apache的方法
- 09-04Apache安装完无法正常启动的解决方法
- 06-27配置 Apache 服务器禁止所有非法域名 访问自己的服务
- 04-05mysql 查看当前使用的配置文件my.cnf的方法
- 03-15Linux下apache目录添加密码的方法
- 10-11公路商店在哪里阅读
- 01-11注册会计师考试聚题库-注册会计师考试
- 08-14织梦DedeCMS更新系统缓存清理冗余缓存
- 11-09QQ音乐取消歌词动态展示步骤分享
- 01-12创意速记-创意速记应用软件功能介绍
- 09-25高德地图趣游路线查询入口介绍
- 10-14苹果13promax定位怎么开
- 11-26搜狗输入法如何设置键盘背景
- 11-21PHP流程控制语句
- 09-04掌上华医在哪里进入继续教育
最近更新
阅读排行
猜你喜欢
- 12-23OPPO手机怎么更改便签视图模式
- 10-10华为nova9pro怎么切换24小时显示
- 01-19想播就播-想播就播应用软件功能介绍
- 12-08华为手机怎么开启悬浮窗功能
- 10-15Linux中locate包的安装与使用
- 11-12微信青少年模式监护人怎么解除
- 03-31小米10s开启区域截屏方法
- 02-10基于PyTorch实现一个简单的CNN图像分
- 10-19iphone13pro怎么新增桌面小组件
- 08-15荣耀magic3怎么开启显示实时网速