Serve precompressed .gz files in Apache2. If the browser does not support gzip compression, the .gz files are decompressed and served as-is.
- Install the apache dev package:
sudo apt-get install apache2-dev
- Make sure the mod_deflate module is enabled:
ls /etc/apache2/mods-enabled/deflate.load
- Compile & install the module:
sudo apxs -cia mod_precompress.c
- Copy the corresponding pre-built 32- or 64- bit library from the win directory to apache/modules
- Add the following line in httpd.conf or apache2.conf:
LoadModule precompress_module modules/mod_precompress.so
- Enable precompression in the /etc/apache2/apache2.conf, in the
<Directory ...>
section:
<Directory />
AllowOverride none
Require all denied
Precompressed on
</Directory>
- Restart Apache:
sudo service apache2 restart
- Compress static data:
cd /var/www/htdocs
gzip index.html