How to install and enable brotli compression on LEMP on ubuntu 18.04

May 1, 2019 1.2k views
LEMP Ubuntu 18.04 Nginx

Hello fellows,

I need some help. I have enabled gzip compression but I also want to enable brotli compression on my server. I followed many articles available on google but none of them helped me to install and enable brotli.

I also don’t trust another source. I followed all the articled by the digital ocean to install my LEMP stack and WordPress. But I think there is no tutorial available for brotli. I also checked official doc of Nginx but there is not enough information. I followed their doc to install brotli but that did not work for me.

Please if anyone here can tell me the best and clean method to enable brotli. I will appreciate that.

Thanks & Regards,
Brajmohan Kumar

1 Answer


To install brotli you need to execute these commands:

sudo apt update
sudo apt install -y build-essential gcc make bc sed autoconf automake libtool git apt-transport-https tree
git clone
cd brotli
sudo cp ~/brotli/docs/brotli.1 /usr/share/man/man1 && sudo gzip /usr/share/man/man1/brotli.1
sudo make install
sudo ldconfig

After that check version with this command brotli --version

Hope this helps

  • Thanks for your guide, will this command work for WordPress over LEMP stack? Do I need to follow any extra step to serve brotli compressed files on my WordPress based website or the above command will manage all and will serve the brotli compressed pages?

    • @techiebraj

      You need to enable brotli for Nginx, I will try to do this and then tell you back how you can do it.

      • @techiebraj

        Hi I searched for a way to enable brotli compression in Nginx and found two possible solutions:

        • First you can use Nginx plus (commercial version of Nginx) and get brotli up and running easily using this page.

        • Second you need to manually compile and install nginx with nginx_brotli module as described here

        Please come back to us if you have further questions.

        Hope any of these helps, best of luck from DO community :)

Have another answer? Share your knowledge.