Bill Lovett

Mod_gzip on Debian Stable's Apache

Posted on June 22nd, 2005

Why didn't I ever look into installing mod_gzip before now? Beats me. But I did, and after a big of head scratching, I got it working.

The thing is, when you go through the usual install process like so:

$ apt-get install libapache-mod-gzip

you don't end up with a fully functioning mod_gzip setup. At least right now, the install script will add the mod_gzip module to Apache's module list in /etc/apache/modules.conf but that's pretty much it. If you consult /usr/share/doc/libapache-mod-gzip/README.Debian, you'll see that you're supposed to handle the rest of the configuration yourself.

Mod_gzip takes a fair bit of configuration, though. I pulled mine from the site suggested in the README. I put my copy in /etc/apache/conf.d. And here we come to gotcha #1-- when I upgraded Apache, I opted to keep my existing httpd.conf so I missed out on the update that allows Apache to load any file placed in conf.d. After a bit of confusion, I realized I had to add this to httpd.conf:

Include /etc/apache/conf.d

But this leads to the bigger gotcha. You may get your mod_gzip configuration right, but not have any proof that it's actually working. The config includes a custom mod_gzip log file that can show you how well mod_gzip's compression is working. You might figure that since the conf.d include line is in httpd.conf, it will carry through to any virtual hosts you've set up. And you'd be wrong.

The fact that you have mod_gzip available and enabled is carried through, but your mod_gzip log configuration isn't necessarily. In my case, I had a virtual host that specified its own custom log apart from the main log files in /var/log/apache. Only when I copied over the mod_gzip LogFormat and CustomLog lines from the config file in conf.d did I start to see the mod_gzip log file start to fill up.

Back to the index of all blog entries