Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1285888
  • 博文数量: 315
  • 博客积分: 10397
  • 博客等级: 上将
  • 技术积分: 3731
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-07 21:21
文章分类

全部博文(315)

文章存档

2015年(10)

2014年(3)

2013年(2)

2012年(8)

2011年(8)

2010年(29)

2009年(59)

2008年(77)

2007年(119)

分类: LINUX

2007-12-28 17:32:43

1、编译时出错
/usr/local/apache2.2.0/bin/apxs -i -a -c mod_deflate.c
提示出错:
Warning!  dlname not found in /usr/local/apache2.2.0/modules/mod_deflate.la.
Assuming installing a .so rather than a libtool archive.
chmod 755 /usr/local/apache2.2.0/modules/mod_deflate.so

后来使用这种方式解决:
gcc -shared -o mod_deflate.so mod_deflate.o
cp mod_deflate.so /usr/local/apache2.2.0/modules
/usr/local/apache2.2.0/bin/apxs -i -a -c mod_deflate.c
 

DeflateCompressionLevel 9
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php
AddOutputFilter DEFLATE css js

DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio

LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
CustomLog logs/deflate_log deflate

大功告成!
Linux下:
"GET / HTTP/1.1" 204/387 (52%)
"GET /phpMyAdmin/ HTTP/1.1" 2474/8045 (30%)
"GET /phpMyAdmin/print.css HTTP/1.1" -/- (-%)
"GET /phpMyAdmin/phpmyadmin.css.php?lang=zh-utf-8&convcharset=iso-8859-1&collation_connection=utf8_unicode_ci&token=90427a95bd0b2420245d29674998be14&js_frame=right&nocache=3591031972 HTTP/1.1" 4329/20539 (21%)
"GET /phpMyAdmin/themes/original/img/b_info.png HTTP/1.1" -/- (-%)
"GET /phpMyAdmin/themes/original/img/b_help.png HTTP/1.1" -/- (-%)
"GET /phpMyAdmin/themes/original/img/logo_right.png HTTP/1.1" -/- (-%)
"GET /phpMyAdmin/themes/original/img/s_notice.png HTTP/1.1" -/- (-%)
"GET /procedure/ HTTP/1.1" 196/342 (57%)
"GET /drupal/ HTTP/1.1" 2578/8861 (29%)
"GET /drupal/modules/system/defaults.css HTTP/1.1" 397/737 (53%)
"GET /drupal/modules/system/system.css HTTP/1.1" 1985/6932 (28%)
"GET /drupal/misc/jquery.js HTTP/1.1" 9903/19340 (51%)
"GET /drupal/modules/user/user.css HTTP/1.1" 367/858 (42%)
"GET /drupal/modules/node/node.css HTTP/1.1" 330/678 (48%)
"GET /drupal/sites/all/modules/fckeditor/fckeditor.css HTTP/1.1" 114/293 (38%)
"GET /drupal/sites/all/modules/tagadelic/tagadelic.css HTTP/1.1" 216/601 (35%)
"GET /drupal/sites/all/modules/cck/content.css HTTP/1.1" 178/368 (48%)
"GET /drupal/sites/all/modules/thickbox/thickbox.css HTTP/1.1" 948/3587 (26%)
"GET /drupal/themes/garland/style.css HTTP/1.1" 4056/16778 (24%)
"GET /drupal/misc/drupal.js HTTP/1.1" 2145/5664 (37%)
"GET /drupal/sites/all/modules/thickbox/thickbox.js HTTP/1.1" 3318/10579 (31%)
"GET /drupal/themes/garland/logo.png HTTP/1.1" -/- (-%)
"GET /drupal/themes/garland/fix-ie.css HTTP/1.1" 713/1412 (50%)
"GET /drupal/themes/garland/print.css HTTP/1.1" 533/1256 (42%)
"GET /drupal/themes/garland/images/body.png HTTP/1.1" -/- (-%)
"GET /drupal/themes/garland/images/menu-collapsed.gif HTTP/1.1" -/- (-%)
"GET /drupal/themes/garland/images/menu-leaf.gif HTTP/1.1" -/- (-%)
"GET /drupal/themes/garland/images/bg-content.png HTTP/1.1" -/- (-%)
"GET /drupal/themes/garland/images/bg-content-right.png HTTP/1.1" -/- (-%)
"GET /drupal/themes/garland/images/bg-content-left.png HTTP/1.1" -/- (-%)
"GET /drupal/themes/garland/images/bg-navigation.png HTTP/1.1" -/- (-%)
"GET /drupal/themes/garland/images/bg-navigation-item-hover.png HTTP/1.1" -/- (-%)
"GET /drupal/themes/garland/images/bg-navigation-item.png HTTP/1.1" -/- (-%)
"GET /drupal/themes/garland/images/bg-tab.png HTTP/1.1" -/- (-%)
 
Windows下:
"GET /kydepot/ HTTP/1.1" 816/1830 (44%)
"GET /kydepot/App/View/rec/css/index.css HTTP/1.1" 795/2274 (34%)
"POST /kydepot/index.php?controller=Default&action=certify HTTP/1.1" 199/280 (71%)
"GET /kydepot/App/View/rec/css/input.css HTTP/1.1" 814/1847 (44%)
"GET /kydepot/index.php?controller=cargo&&action=list HTTP/1.1" 1621/12555 (12%)
"GET /kydepot/App/View/rec/css/input.css HTTP/1.1" 814/1847 (44%)
"GET /kydepot/index.php?controller=Cargo&action=List&page=1 HTTP/1.1" 1601/12854 (12%)
"GET /kydepot/App/View/rec/css/input.css HTTP/1.1" 814/1847 (44%)
"GET /kydepot/index.php?controller=cargo&&action=show HTTP/1.1" 1750/17412 (10%)
"GET /kydepot/App/View/rec/css/cargo.css HTTP/1.1" 708/1734 (40%)
"GET /kydepot/index.php?controller=Cargo&action=Detail&recid=0.4DA-PBA(TA) HTTP/1.1" 1294/4837 (26%)
"GET /kydepot/App/View/rec/css/cgdetail.css HTTP/1.1" 730/1944 (37%)
 

2. 安装mod_deflate

/usr/local/apache224/bin/apxs  -i -c -a mod_deflate.c

apxs命令参数说明:
-i  此选项表示需要执行安装操作,以安装一个或多个动态共享对象到服务器的modules目录中。
-a  此选项自动增加一个LoadModule行到httpd.conf文件中,以激活此模块,或者,如果此行已经存在,则启用之。
-A  与 -a 选项类似,但是它增加的LoadModule命令有一个井号前缀(#),即此模块已经准备就绪但尚未启用。
-c  此选项表示需要执行编译操作。它首先会编译C源程序(.c)files为对应的目标代码文件(.o),然后连接这些目标代码和files中其余的目标代码文件(.o和.a),以生成动态共享对象dsofile 。如果没有指定 -o 选项,则此输出文件名由files中的第一个文件名推测得到,也就是默认为mod_name.so 。
 
如果是新安装apache,直接加上  --enable-headers --enable-deflate 即可

3. 配置mod_deflate

vi /usr/local/apache224/conf/httpd.conf
LoadModule deflate_module     modules/mod_deflate.so

此LoadModule需要放在libphp5.so之后


 DeflateCompressionLevel 7
 AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php
 AddOutputFilter DEFLATE css js


压缩等级的调整有两种说法,不过懒得研究了,默认等级是6,890k的文件压缩出来的数据和最高的9级只差1k,而且9级需要更多的CPU时间,用默认的6级就可以了。

阅读(1889) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~