• 欢迎访问MACD实战投资网站,推荐使用最新版谷歌Chrome浏览器访问本网站,关注公众号 丁火甲木庚金 www.macd11.com/subscriptions

为Apache配置mod_deflat压缩输出

未分类 丁火 15年前 (2010-06-26) 874次浏览 0个评论

  1、如果未安装Apache。编译时,加上–enable-deflate,例如:(仅针对Linux版,Windows版无须此步骤)
  

./configure –prefix=/usr/local/apache –enable-rewrite –enable-so –enable-deflate

  2、如果已安装Apache。添加mod_deflate模块,例如:(仅针对Linux版,Windows版无须此步骤)

/usr/local/apache/bin/apxs -i -a -c /home/zhangyan/software/httpd-2.0.59/modules/filters/mod_deflate.c

  注:/home/zhangyan/software/httpd-2.0.59/为Apache源码路径。

  3、进行以上步骤后,会在httpd.conf中自动加入一行:(Windows版请将下行最前面的#号去掉)

LoadModule deflate_module modules/mod_deflate.so

  4、编辑 httpd.conf,增加:
  Linux版:


DeflateCompressionLevel 9
SetOutputFilter DEFLATE
#DeflateFilterNote Input instream
#DeflateFilterNote Output outstream
#DeflateFilterNote Ratio ratio
#LogFormat ‘”%r” %{outstream}n/%{instream}n (%{ratio}n%%)’ deflate
#CustomLog logs/deflate_log.log deflate

   Windows版:


DeflateCompressionLevel 9
SetOutputFilter DEFLATE
#DeflateFilterNote Input instream
#DeflateFilterNote Output outstream
#DeflateFilterNote Ratio ratio
#LogFormat ‘”%r” %{outstream}n/%{instream}n (%{ratio}n%%)’ deflate
#CustomLog logs/deflate_log.log deflate

  如果将#号去掉,可以在logs/deflate_log.log日志文件中看到文件压缩前后的字节数、压缩比,例如:
  ”GET /index.html HTTP/1.1″ 49373/276249 (17%)
  压缩前的字节数为276249,压缩后的字节数为 49373,压缩比为17%

  5、详细配置见Apache官方网站:http://httpd.apache.org/docs/2.0/mod/mod_deflate.html

作者:张宴


macd11.com 和 丁火甲木庚金 公众号版权所有丨如未注明 , 均为原创丨转载请注明原文链接。
喜欢 (0)
[sp91@qq.com]
分享 (0)

您必须 登录 才能发表评论!