Skip to main content

How to install mod_brotli on Directadmin CentOS 8

Just like gzip, Brotli is also a compression algorithm. It is developed by Google and serves best for text compression. The reason being, it uses a dictionary of common keywords and phrases on both client and server side and thus gives a better compression ratio. The advantage for Brotli over gzip is that it makes use of a dictionary and thus it only needs to send keys instead of full keywords. It is supported by all major browsers. Fewer bytes transferred not only leads to faster page load but also helps in reducing costs of Content Delivery Network (CDN).

1. Install Brotli Apache module

  • dnf install epel-release and enable the repo
  • Installed Brotli package on Centos 8 (dnf install brotli brotli-devel)
  • Added brotli module to apache for custombuild, following: https://help.directadmin.com/item.php?id=191 (–with-brotli)
  • Check if the brotli module is really active in Apache:
    httpd -t -D DUMP_MODULES

 

2. Brotli Compression Installed But Not Available In W3TC

Install the PHP Extension:

NEW METHOD (PHP 8.2):

pecl install brotli

sudo touch /usr/local/php82/lib/php.conf.d/php-brotli.ini && echo extension=brotli.so > /usr/local/ph82/lib/php.conf.d/php-brotli.ini

systemctl restart php-fpm82.service

 

OLD METHOD (PHP 7.4 & PHP 8.1):

https://wordpress.org/support/topic/brotli-compression-installed-but-not-available-in-w3tc/

https://github.com/kjdev/php-ext-brotli

Add Brotli extension to PHP 7.4

sudo touch /usr/local/php74/lib/php.conf.d/php-brotli.ini && echo extension=brotli.so > /usr/local/php74/lib/php.conf.d/php-brotli.ini
systemctl restart php-fpm74

W3 Total Cache

Enable Brotli Compression in W3 Total Cache > Browser Cache.

Disable Gzip Compression in W3 Total Cache > Browser Cache.

Test Brotli

https://tools.keycdn.com/brotli-test

https://www.brotli.pro/

Geef een reactie

Het e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *