What is Brotli and Why?
- ROOT user login credentials
- Access to WHM Panel
- Access to SSH Terminal
Install Brotli Apache Module
Login to WHM then navigate to Home »Software »EasyApache 4 and click on Customize
then select Apache Modules in the next page and search for mod_brotli
keep clicking on the Next buttons and finish the installation by clicking Provision in the last step.
Install Brotli PHP Extension
As cPanel doesn’t offer PHP Extension for Brotli through EasyApahe 4 so we will use a custom shell script to install Brotli PHP Extension. Please copy everything below and run at once –
for phpver in $(ls -1 /opt/cpanel/ |grep ea-php | sed 's/ea-php//g') ; do
git clone --recursive --depth=1 https://github.com/kjdev/php-ext-brotli.git
cd ~/php-ext-brotli* || exit
make && make install
echo 'extension=brotli.so' > /opt/cpanel/ea-php"$phpver"/root/etc/php.d/brotli.ini
rm -rf ~/php-ext-brotli*
this should finish the Brotli PHP Extension installation for you. Please don’t forget to restart Apache (httpd) and PHP-FPM once you finished installation using below commands –
Confirm Brotli and Brotli PHP Extension Installation
As we already have installed both Brotli Apache Module and Brotli PHP Extension, let’s verify if they are loaded and ready to use. Please run below command –
httpd -M |grep brotli; php -i |grep “Brotli support”
Brotli support => enabled
If the output above matches then the installation of Brotli Apache Module and Brotli PHP Extension installation is successful.
Feel free to post comments if you face any issues with this tutorial and I would be happy to help. Also, check out these articles –
How to get Google BBR on CentOS 7
How to get NGINX on cPanel and WHM
thank you. the only tutorial that does not suck
You’re welcome, let me know if you’ve still got any questions.
thanks you for tutorial. working on myserver