Install php-ext-brotli on CWP PHP Switcher, CGI Selector and PHP-FPM selector

In this tutorial we’re going to install php-brotli on cwp server with switcher, CGI selector and php-fpm selector. This PHP extension allows Brotli compression which are used to compress files as well as serving cached resources by various applications/plugins.

Brotli is a generic-purpose lossless compression algorithm that compresses data using a combination of a modern variant of the LZ77 algorithm, Huffman coding and 2nd order context modeling, with a compression ratio comparable to the best currently available general-purpose compression methods. It is similar in speed with deflate but offers more dense compression.

Without wasting time lets get started :

Install Google brotli :

yum install pcre-devel cmake git -y
cd /usr/local/src
git clone https://github.com/google/brotli.git
cd brotli
./configure-cmake
make && make install

In CWP there are three php modules i.e switcher (free for all), cgi selector (pro needed) and php-fpm selector (pro needed) ensure you’ve pro licensee in order to use cgi and fpm selector.

Brotli PHP Switcher installation :

cd /usr/local/src
rm -rf php-ext-brotli
git clone --recursive --depth=1 https://github.com/kjdev/php-ext-brotli.git
cd php-ext-brotli
phpize
./configure
make && make install

then add php extension ini file, run below command one by one:

touch /usr/local/php/php.d/brotli.ini
grep "brotli.so" /usr/local/php/php.d/brotli.ini || echo "extension=brotli.so" >> /usr/local/php/php.d/brotli.ini

Brotli PHP Selector (CGI) installation :

cd /usr/local/src
rm -rf php-ext-brotli
git clone --recursive --depth=1 https://github.com/kjdev/php-ext-brotli.git
cd php-ext-brotli
/opt/alt/php74/usr/bin/phpize
./configure  --with-php-config=/opt/alt/php74/usr/bin/php-config
make && make install

then add php extension ini file, run below command one by one:

touch /opt/alt/php74/usr/php/php.d/brotli.ini
grep "brotli.so" /opt/alt/php74/usr/php/php.d/brotli.ini || echo "extension=brotli.so" >> /opt/alt/php74/usr/php/php.d/brotli.ini

Here you need to change highlighted in red for other php cgi selector version i.e.
replace php74 with php73 for php 7.3.x installation
replace php74 with php72 for php 7.2.x installation
replace php74 with php71 for php 7.1.x installation
replace php74 with php70 for php 7.0.x installation
replace php74 with php56 for php 5.6.x installation

Brotli PHP-FPM Selector installation :

cd /usr/local/src
rm -rf php-ext-brotli
git clone --recursive --depth=1 https://github.com/kjdev/php-ext-brotli.git
cd php-ext-brotli
/opt/alt/php-fpm74/usr/bin/phpize
./configure  --with-php-config=/opt/alt/php-fpm74/usr/bin/php-config
make && make install

then add php extension ini file, run below command one by one:

touch /opt/alt/php-fpm74/usr/php/php.d/brotli.ini
grep "brotli.so" /opt/alt/php-fpm74/usr/php/php.d/brotli.ini || echo "extension=brotli.so" >> /opt/alt/php-fpm74/usr/php/php.d/brotli.ini

Here you need to change highlighted in red for other php-fpm selector version i.e.
replace php-fpm74 with php-fpm73 for php 7.3.x installation
replace php-fpm74 with php-fpm72 for php 7.2.x installation
replace php-fpm74 with php-fpm71 for php 7.1.x installation
replace php-fpm74 with php-fpm70 for php 7.0.x installation
replace php-fpm74 with php-fpm56 for php 5.6.x installation

after that restart/reload php-fpm service from cwp php-fpm module.

this tutorial was requested by Automata in our forum – Link here
Back to top button