The Netlobo logo - a Nevada desert landscape

Enable mod_deflate on Novell's SUSE Linux Enterprise Server 10

A quick tutorial to get mod_deflate working in SUSE Linux Enterprise Server 10 in order to save bandwidth and make your web pages faster.

Published Sep 20, 2008 by lobo235
Last updated on Sep 20, 2008

Enabling compression in Apache2 using mod_deflate has multiple benefits. First off, you will use a lot less bandwidth than you did before which can save you money on hosting costs. Secondly, it can make your pages load more quickly for you users, search engine bots, etc which makes your site seem much more responsive and cutting-edge. With these simple steps you will be able to enable mod_deflate in Novell's SUSE Linux Enterprise Server 10.

Getting Started

Login to the server via SSH or locally. In order to have permission to edit the required files you will need to switch to the root user. You can switch to root by typing 'su' in the terminal and then you'll be prompted to input the password for for the root user.

Turn on mod_deflate

As root you need to edit the '/etc/sysconfig/apache2' file using your favorite text editor. In the file, find the line that begins with 'APACHE_MODULES=' and you will see a list of the modules that apache will load when it starts up. Add the word 'deflate' to the list of modules. The modules are usually alphabetized, so if you want, you can put 'deflate' in the correct position to keep it that way but it's not necessary. Save the file and we'll move on to the next step.

Tell mod_deflate which files to compress

If you are just using the default configuration you will need to use the '/etc/apache2/default-server.conf' in this step. If you are using a virtual host or some other advanced configuration you will need to open the conf file you have created for that setup. Open the conf file and find the '<Directory>' tag that corresponds to your server and add the following line just above the '</Directory>' tag:

AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml text/javascript application/x-javascript application/json

This tells mod_deflate that it should compress HTML, CSS, Plain Text, XML, Javascript, and JSON output from the server. Save the file.

Restart Apache

Now all you need to do is restart apache2 using the following command: '/etc/init.d/apache2 restart'
After Apache restarts the above output types should be compressed when sent to your visitor's browsers as long as their browser supports compression.

Adding a deflate log

It can be benificial to add a log that keeps track of which files are being compressed and by how much they are being compressed. To do this, open the '/etc/apache2/mod_log_config.conf' file and add the following at the bottom:

<IfModule mod_deflate.c>
DeflateFilterNote Input input_info
DeflateFilterNote Output output_info
DeflateFilterNote Ratio ratio_info
LogFormat '"%t %h %r" %{output_info}n/%{input_info}n (%{ratio_info}n%%)' deflate
CustomLog /var/log/apache2/deflate_log deflate
</IfModule>

You now have compression working on your apache2 server under SUSE Linux Enterprise Server 10.

0 comments for this article.

del.icio.us logo add this article to del.icio.us!
Other great Linux articles on Netlobo.com:
How To Enable Apache Modules in Ubuntu