Archive for March 2009

Adding mod_deflate to Apache as a shared object

So you want to add mod_deflate to Apache but without recompiling it. You can compile just that module and add it dynamically.

What we need to do is create mod_deflate.so where the .so stands for shared object.

First find where apxs and apr-config are located. For me it was in /usr/local/apache/bin

Edit the apr-config file and change this line:

LDFLAGS=""

to this one:

LDFLAGS="-lz"

Then go to your Apache source files (or download them off of apache.org). Go to modules/filters and find the mod_deflate.c file.

Run this:

apxs -c mod_deflate.c

You should now have these files:

mod_deflate.c
mod_deflate.dsp
mod_deflate.exp
mod_deflate.la
mod_deflate.lo
mod_deflate.o
mod_deflate.slo

Notice there is no mod_deflate.so file there. This is where I got stuck. Fortunately on Apache’s site they indicate to do this:

apxs -i -a -n deflate mod_deflate.la

That creates the mod_deflate.so file, puts it in the modules folder, and adds this to your httpd.conf:

LoadModule deflate_module modules/mod_deflate.so

There you go.