Apache Server Configuration and httpd.conf / .htaccess

Sample Configurations

The HTML5 Boilerplate project contains sample configuration files for all the most popular servers with detailed comments for each configuration flag and setting: find your favorite server in the list, look for the gzip section, and confirm that your server is configured with recommended settings.

Copy and use the .htacces template template.

You need to enable the Apache mods required for the configurations used in the template. On Linux, open a terminal and:

sudo a2enmod setenvif headers deflate filter expires rewrite include 
sudo /etc/init.d/apache2 restart

Enabling Website Compression in WHM/cPanel

If on a CentOS/cPanel server, use EasyApche to enable the ‘Deflate’ module. Software > EasyApache (Update Apache). Once you have the ‘Deflate’ module enabled, you’ll have to enable compression for each individual website under cPanel > Software/Services > Optimize Website.

See the cPanel documentation about enabling mod_deflate and using the ‘Optimize Website’ option.

Further Reading