The following assumptions will be used throughout this article:
- Apache is installed in /usr/local/apache2 directory
- Apache Source Code version is 2.0.59
- Apache Source code is uncompressed in /home/user directory
The three assumptions above will be dependent on your system setup and should be changed in the commands below as(if) appropriate.
- Hack apr-config located in the /usr/local/apache2/bin directory so the LDFLAGS will have the "-lz" value similar below:
LDFLAGS="-lz"
- Download and extract apache httpd source code and navigate to the /home/user/httpd-2.0.59/modules/filters directory
- Run the following command while in the modules/filters directory:
/usr/local/apache2/bin/apxs -c mod_deflate.c
- Copy the compiled mod_deflate.so into the apache2/modules directory using the following command:
cp .libs/mod_deflate.so /usr/local/apache2/modules/
- Edit the Apache configuration (apache2/conf/httpd.conf) and append the following lines:
LoadModule deflate_module modules/mod_deflate.so
# Insert filter
SetOutputFilter DEFLATE
# 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
# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
- Restart apache by invoking the following command while in the apache2/bin directory
apachectl restart
if on ssl, stop apachectl first and restart in ssl modeapachectl stop
apachectl startssl