How to install mod_brotli (Apache Brotli) on Ubuntu 16.04

sudo apt-get install -y git make automake libtool apache2-dev

if [[ -d "$HOME/tmp/git/apache-mod-brotli" ]]; then
  cd "$HOME/tmp/git/apache-mod-brotli"
  git pull
  mkdir -p "$HOME/tmp/git"
  cd "$HOME/tmp/git"
  git clone --depth=1 --recursive ""
  cd "apache-mod-brotli"
make clean
make distclean

sudo mkdir -p "/usr/lib/apache2/modules"
sudo chown root:root "/usr/lib/apache2/modules"
sudo chmod 0755 "/usr/lib/apache2/modules"
sudo install -p -m 755 -D .libs/ "/usr/lib/apache2/modules/"
sudo ldconfig

sudo mkdir -p "/etc/apache2/mods-available"
sudo chown root:root "/etc/apache2/mods-available"
sudo chmod 0755 "/etc/apache2/mods-available"
echo "LoadModule brotli_module /usr/lib/apache2/modules/" | sudo tee "/etc/apache2/mods-available/brotli.load"

sudo bash -c "cat > '/etc/apache2/mods-available/brotli.conf' <<'EOL'

    BrotliCompressionLevel 10
    BrotliWindowSize 22
    BrotliAlterEtag AddSuffix
    BrotliFilterNote Input brotli_in
    BrotliFilterNote Output brotli_out
    BrotliFilterNote Ratio brotli_ratio
    AddOutputFilterByType BROTLI text/html text/plain text/css text/xml
    AddOutputFilterByType BROTLI text/css
    AddOutputFilterByType BROTLI application/x-javascript application/javascript
    AddOutputFilterByType BROTLI application/rss+xml
    AddOutputFilterByType BROTLI application/xml
    AddOutputFilterByType BROTLI application/json


sudo a2enmod brotli

sudo service apache2 restart

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.