Skip to content

Instantly share code, notes, and snippets.

@fvztdk
Created December 28, 2018 09:31
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save fvztdk/96dc2bd02788d60ce1da637b3834ae30 to your computer and use it in GitHub Desktop.
Build and install google brotli nginx as a dynamic module (ubuntu xenial)
#install brotli
sudo apt-get install brotli
#check nginx version
nginx -V
#download nginx source
wget http://nginx.org/download/nginx-1.14.1.tar.gz
#extract the source
tar -xzvf nginx-1.14.1.tar.gz
#clone the official nginx brotli module
git clone --recursive https://github.com/google/ngx_brotli.git
#get the nginx build dependecies
sudo apt-get build-dep nginx
#configure the build
nginx -V 2>&1 >/dev/null | grep -o " --.*" | grep -oP .+?(?=--add-dynamic-module)| head -1 > nginx-1.14.1/build_args.txt
cd nginx-1.14.1
./configure --with-compat $(cat build_args.txt) --add-dynamic-module=../ngx_brotli
make install
#copy the dynamic module to your nginx lib
sudo cp objs/ngx_http_brotli_filter_module.so /usr/lib/nginx/modules/
sudo chmod 644 /usr/lib/nginx/modules/ngx_http_brotli_filter_module.so
sudo cp objs/ngx_http_brotli_static_module.so /usr/lib/nginx/modules/
sudo chmod 644 /usr/lib/nginx/modules/ngx_http_brotli_static_module.so
#in yor nginx.conf use
# load_module /usr/lib/nginx/modules/ngx_http_brotli_filter_module.so;
# load_module /usr/lib/nginx/modules/ngx_http_brotli_static_module.so;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment