Setting up mod_gzip in Apache

Warning: This article/tutorial is more the 45 days old. As such the information contained within could be, by now, out of date. Please read all information to make sure that this article/tutorial will work with your current version of the Operating System

FYI In response to feedback from “jeanloui”, several changes have been made to this article.

The mod_gzip module for Apache will compress the pages as it sends them. Of course, it will only do this if the browser that your audience is using is compatible. Before you do this tutorial, run your website through PipeBoost to see how fast it currently is.


1. Download the latest version of mod_gzip from SourceForge.

2. De-compress it.

3. Using TextEdit, or your favourite editor, make the following changes to the Makefile in the folder.





$(APXS) -Wc,-Wall,-O3,-fomit-frame-pointer,-pipe -c mod_gzip.c mod_gzip_debug.c mod_gzip_compress.c -o


$(APXS) -Wc,-Wall,-O3,-fomit-frame-pointer,-pipe -c mod_gzip.c mod_gzip_debug.c mod_gzip_compress.c

4. Save the file.

5. Run “make” in the Terminal in the directory.

6. Run “sudo make install”, entering your password when requested.

7. Run “sudo pico /etc/httpd/httpd.conf”

8. Uncomment, that is remove the # from the front of (if it is not already done), these lines:

LoadModule gzip_module libexec/httpd/
AddModule mod_gzip.c
AddEncoding x-compress Z
AddEncoding x-gzip gz tgz

9. Still in pico, add these lines to the end of the file:

mod_gzip_on Yes
mod_gzip_can_negotiate Yes
mod_gzip_static_suffix .gz
AddEncoding gzip .gz
mod_gzip_update_static No
mod_gzip_command_version ‘/mod_gzip_status’
mod_gzip_temp_dir /var/mod_gzip_temp_dir
mod_gzip_keep_workfiles No
mod_gzip_minimum_file_size 500
mod_gzip_maximum_file_size 500000
mod_gzip_maximum_inmem_size 60000
mod_gzip_min_http 1000
mod_gzip_handle_methods GET POST
mod_gzip_item_exclude reqheader “User-agent: Mozilla/4.0[678]”
mod_gzip_item_include file .html$
mod_gzip_item_include file .shtml$
mod_gzip_item_include file .htm$
mod_gzip_item_include file .shtm$
mod_gzip_item_include file .php$
mod_gzip_item_include file .phtml$
mod_gzip_item_exclude file .js$
mod_gzip_item_exclude file .css$
mod_gzip_item_include file .pl$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/html$
mod_gzip_item_include mime ^text/plain$
mod_gzip_item_include mime ^httpd/unix-directory$
mod_gzip_item_exclude mime ^image/
mod_gzip_dechunk Yes
mod_gzip_add_header_count Yes
mod_gzip_send_vary Yes

10. Save the file with Control-O.

11. Run “cd /etc”. Then “ls php*” to see if there is a file called “php.ini”. If there is only “php.ini.default” then run “sudo cp php.ini.default php.ini”.

12. Run “sudo pico php.ini”. Look for:

zlib.output_compression = On


zlib.output_compression = On

13. Save the file with Control-O.

14. Restart Apache with “sudo apachectl restart”

15. Test your website again with PipeBoost and notice the difference!

Credit for this article is due to to Christoper Holland at Exordium

John Lunney marked-up and made slight changes to it.

Leave a Reply

Your email address will not be published. Required fields are marked *