mod_deflate,gzip,httpd
#cd /usr/local/apache2/bin
#httpd -v
Server version: Apache/2.0.52
#vi apr-config
LDFLAGS="-lz"
#tar -xvzf httpd-2.0.52.tar.gz
#cd /data/src/httpd-2.0.52/modules/filters
#/usr/local/apache2/bin/apxs -i -c -a mod_deflate.c
#/usr/local/apache2/bin/apxs -i -c -a mod_headers.c
#vi /usr/local/apache2/conf/httpd.conf
#压缩率, 6是建议值.
<ifmodule mod_deflate.c>
DeflateCompressionLevel 6
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/js
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE image/svg+xml
</ifmodule>
=================================================================================================================================
其中 {apache-bin} 为 Apache 安装目录下的 bin 目录,接下来在 httpd.conf 直接配置该模块即可。
很多时候你在单独编译 deflate 模块的时候可能会碰到编译错误,提示是:
Cannot load /opt/apache/modules/mod_deflate.so into server: /opt/apache/modules/mod_deflate.so: undefined symbol: deflate
解决的方法如下:
编辑 /usr/local/apache2/bin/apr-config 文件修改其中的 LDFLAGS 值为 "-lz",然后再重新编译 mod_deflate 模块,apxs -ica mod_deflate.c 即可。
为了省却不必要的麻烦,请尽量在编译安装时直接加上 --enable-deflate --enable-headers 参数。
如果重启的时候出现错误
引用
Cannot load /usr/local/apache/modules/mod_deflate.so into server: /usr/local/apache/modules/mod_deflate.so: undefined symbol: inflateEnd
需要在 LoadModule deflate_module modules/mod_deflate.so 的前面加载zlib.so
这里需要注意的是LoadModule deflate_module需要放在LoadModule php5_module之后
引用
LoadFile /usr/lib/libz.so
LoadModule deflate_module modules/mod_deflate.so