Aarvi

Install Brotli on Apache 2.4 on cPanel

root@server /]# yum install brotli
Loaded plugins: fastestmirror, getpagespeed, universal-hooks
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 8.6 kB 00:00:00

EA4: 208.74.123.61
cpanel-addons-production-feed: 208.74.123.61
cpanel-plugins: 208.74.123.61
base: mirrors.radwebhosting.com
epel: pubmirror2.math.uh.edu
extras: centos.mirror.lstn.net
updates: repos.dfw.quadranet.com
Resolving Dependencies
–> Running transaction check
—> Package brotli.x86_64 0:1.0.7-5.el7 will be installed
–> Finished Dependency Resolution
Dependencies Resolved

Package Arch Version Repository Size
Installing:
brotli x86_64 1.0.7-5.el7 epel 318 k

Transaction Summary
Install 1 Package

Total download size: 318 k
Installed size: 1.5 M
Is this ok [y/d/N]: y
Downloading packages:
brotli-1.0.7-5.el7.x86_64.rpm | 318 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : brotli-1.0.7-5.el7.x86_64 1/1
Verifying : brotli-1.0.7-5.el7.x86_64 1/1

Installed:
brotli.x86_64 0:1.0.7-5.el7

Complete!

Now go to Home »Service Configuration »Apache Configuration >> Include Editor >> Pre main include

Add below entries and save a

<IfModule mod_brotli.c>
AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/x-javascript application/javascript application/json application/x-font-ttf application/vnd.ms-fontobject image/x-icon
</IfModule>
Check using below command to find encoding. It should show br

[root@server /]# curl -I -H ‘Accept-Encoding: br’ https://tuanpools.com
HTTP/1.1 200 OK
Date: Wed, 28 Oct 2020 14:31:36 GMT
Server: Apache
Link: https://tuanpools.com/wp-json/; rel=”https://api.w.org/”
Vary: Accept-Encoding
Content-Encoding: br
Content-Length: 1
Content-Type: text/html; charset=UTF-8

[root@server /]#