Install Brotli Compression on Ubuntu 20.04

This tutorial intends to teach you to Install Brotli Compression on Ubuntu 20.04.

Brotli is an open-source, lossless compression algorithm introduced by Google in 2015.

Brotli is built using a modern version of the LZ77 algorithmHuffman coding, and 2nd-order context modeling.

The algorithm utilizes a dictionary already built into users’ browsers that consists of almost 100,000 commonly used phrases and word fragments on the web. Due to this, it is possible to reduce the size of the files being processed.

Steps To Install Brotli Compression on Ubuntu 20.04

To complete this guide, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide the Initial Server Setup with Ubuntu 20.04.

In this guide, you will learn to install Brotli from the source.

Install Brotli From Source on Ubuntu 20.04

First, you need to update your local package index with the command below:

sudo apt update

Install Required packages

Then, install the required packages and dependencies with the command below:

sudo apt install -y wget gcc make bc sed autoconf automake libtool git tree

Clone Brotli Repo From GitHub

At this point, you need to clone the Brotli repository from GitHub on Ubuntu 20.04 with the following command:

sudo git clone https://github.com/google/brotli.git

Switch to your Brotli directory:

cd brotli

Create a Manual Page for Brotli

Next, create a manual page for the Brotli command:

sudo cp ~/brotli/docs/brotli.1 /usr/share/man/man1 && sudo gzip /usr/share/man/man1/brotli.1

Generate Autotools Configure File

To generate the Autotools configure file, run the following command:

./bootstrap

Now you have access to the usual C program build steps: configuremake and make install available.

Build and Install Brotli

At this point, you can build and install Brotli on Ubuntu 20.04 with the following commands:

# ./configure --prefix=/usr \
            --bindir=/usr/bin \
            --sbindir=/usr/sbin \
            --libexecdir=/usr/lib64/brotli \
            --libdir=/usr/lib64/brotli \
            --datarootdir=/usr/share \
            --mandir=/usr/share/man/man1 \
            --docdir=/usr/share/doc
# make
# sudo make install

When you are finished, you can verify your Brotli installation on Ubuntu 20.04 by checking its version:

brotli --version

Also, you can use the following command to get more help about the brotli command:

brotli -h
Output
Usage: brotli [OPTION]... [FILE]...
Options:
-# compression level (0-9)
-c, --stdout write on standard output
-d, --decompress decompress
-f, --force force output file overwrite
-h, --help display this help and exit
-j, --rm remove source file(s)
-k, --keep keep source file(s) (default)
-n, --no-copy-stat do not copy source file(s) attributes
-o FILE, --output=FILE output file (only if 1 input file)
-q NUM, --quality=NUM compression level (0-11)
-t, --test test compressed file integrity
-v, --verbose verbose mode
-w NUM, --lgwin=NUM set LZ77 window size (0, 10-24)
window size = 2**NUM - 16
0 lets compressor choose the optimal value
--large_window=NUM use incompatible large-window brotli
bitstream with window size (0, 10-30)
WARNING: this format is not compatible
with brotli RFC 7932 and may not be
decodable with regular brotli decoders
-D FILE, --dictionary=FILE use FILE as raw (LZ77) dictionary
-S SUF, --suffix=SUF output file suffix (default:'.br')
-V, --version display version and exit
-Z, --best use best compression level (11) (default)
Simple options could be coalesced, i.e. '-9kf' is equivalent to '-9 -k -f'.
With no FILE, or when FILE is -, read standard input.
All arguments after '--' are treated as files.

Conclusion

Data compression is a necessary component of developing and using the modern web. File sizes can skyrocket due to the rich and complex file types you’ll use to piece together a website. All of them need some form of compression.

Brotli compression bases its technology on the same foundation as GZIP but includes some performance-enhancing benefits.

At this point, you have learned to Install Brotli Compression on Ubuntu 20.04.

Hope you enjoy it.

You may be interested in these articles:

Install PHP 8.2 on Ubuntu 20.04

Install Python 3.11 on Ubuntu 20.04

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

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

Stay informed and not overwhelmed, subscribe now!