Using Apache mod_deflate on Solaris10

June 8, 2007 – 8:07 pm

One of the easiest ways to quickly improve your web site's perceived performance is to use compression to decrease the size of the data transfer. Especially with increased use of javascript and css that comes with "web 2.0-ification ", using data compression is pretty much a no-brainer if you have the CPU overhead. Several years ago, the use of compression on the web server was lot more complicated, since not all browsers supported the gzip or deflate content-encoding type. Nowadays, you'd have a hard time finding a browser that doesn't support it.

The good news is Apache web server comes with an easy to configure compression called mod_deflate. The bad news is that it almost never is compiled as a module by default and on Solaris 10 (which comes with Apache web server pre-installed, by the way), it can be a little tricky getting it to work.

The first thing you'll need to do is download the Apache http server source code and un-tar wherever you would like to keep it (e.g. /usr/local/src)

By far the easiest way to add a module to an existing Apache installation is to use the "apxs" tool: http://httpd.apache.org/docs/2.0/programs/apxs.html. I won't go through the details of this since the Apache documentation does a fine job. However, on the Solaris10 installation of Apache, you will probably run into a few snags.

First, if you are going to add a module to the Apache installation of Solaris10, you'll most likely want (need?) to use the SunStudio development tools (compiler and linker) that were used to compile the Apache web server that came with your Solaris10. Luckily, this is a free, albeit large, download available from Sun.

Once you have SunStudio installed, you can run apxs in the Apache bin directory (/usr/apache2/bin) and libtool will be able to find the linker (ld). The SunStudio cc compiler should be in your path. This should work for you:

cd /usr/apache2/bin; apxs -c -i /path/to/apache/source/modules/filters/mod_deflate.c

After compiling, run ldd to make sure the compression library was linked into your module. If not, you'll need to follow the procedure outlined on this blog in order to avoid fatal errors loading mod_deflate.

Here are some additional links you may find useful:

http://httpd.apache.org/docs/2.0/mod/mod_deflate.html

http://httpd.apache.org/docs/2.0/dso.html


Post a Comment