Compile Apache With Mod Deflate

Compile Apache with mod_deflate

cd /usr/local/src
rm -Rf httpd-2.0.63
tar -xvjf httpd-2.0.63.tar.bz2

./configure --prefix=/usr/local/apache.2.0.63-deflate --enable-rewrite --enable-ssl --with-mpm=prefork --enable-auth-digest --enable-ssl --enable-deflate --enable-headers --disable-include  --disable-env  --enable-status --disable-asis  --disable-cgi  --disable-negotiation --disable-autoindex --disable-imap  --disable-actions  --disable-userdir  --disable-alias && make && make install

Copy old configuration files

cp -fa /usr/local/apache/conf/* /usr/local/apache.2.0.63-deflate/conf/
cp -fa /usr/local/apache/logs/* /usr/local/apache.2.0.63-deflate/logs/
cp -fa /usr/local/apache/modules/* /usr/local/apache.2.0.63-deflate/modules/

Create a file called /usr/local/apache.2.0.63-deflate/conf/deflate.conf with the following content:

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# 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

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary

DeflateCompressionLevel 9

DeflateFilterNote Ratio ratio_info

Add the following line to /usr/local/apache.2.0.63-deflate/conf/httpd.conf

LogFormat "\"%h\",\"%l\",\"%u\",\"%t\",\"%r\",\"%>s\",\"%b\",\"%{Referer}i\",\"%{User-Agent}i\",\"%{Cookie}i\",\"%{ratio_info}n%%\"" combineddeflate

In /usr/local/apache.2.0.63-deflate/conf/httpd.conf


Include conf/secure.conf
Include conf/httpd-hummy.conf


Include conf/secure.conf
Include conf/deflate.conf
Include conf/httpd-hummy.conf

In /usr/local/apache.2.0.63-deflate/conf/httpd-hummy.conf for ALL virtual hosts change:


CustomLog "|/usr/local/sbin/cronolog /home/ulysse/logs/apache/%Y/%m/%Y-%m-%d.bf2.acc.log" combinedcookie


CustomLog "|/usr/local/sbin/cronolog /home/ulysse/logs/apache/%Y/%m/%Y-%m-%d.bf2.acc.log" combineddeflate

Check new apache syntax

/usr/local/apache.2.0.63-deflate/bin/apachectl -t

Substitute the current apache

cd /usr/local
/etc/init.d/apache stop
rm apache
ln -s apache.2.0.63-deflate apache
/etc/init.d/apache start


Put previous Apache config in place and restart

/etc/init.d/apache stop

cd /usr/local
rm apache
ln -s apache.2.0.63 apache

/etc/init.d/apache start

Important There is a bug in mod_jrun. In order to compress html and xml returned by cfm pages, the connector source has to be changed following these intructions:

And then compiled following these intructions:


After doing this, you will have to fix AWSTATS

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License