What is Brotli? Here is a quote from Google:
Brotli is a generic-purpose lossless compression algorithm that compresses data using a combination of a modern variant of the LZ77 algorithm, Huffman coding and 2nd order context modeling, with a compression ratio comparable to the best currently available general-purpose compression methods. It is similar in speed with deflate but offers more dense compression.
We will not repeat the installation of nginx here. Start installing the Brotli module now:
1.get the ngx_brotli
1 2 3 4 5 6 7 |
cd /www/server/nginx/src #The module directory in the aaPanel. You can change it to your own directory. git clone https://github.com/google/ngx_brotli.git cd /www/server/nginx/src/ngx_brotli && git submodule update --init |
2.Install the Brotli module
1 |
cd /www/server/nginx/src |
use the nginx -V to see the nginx’s config , then use the ./configure add the ngx_brotli to the last.
--add-module=/www/server/nginx/src/ngx_brotli
The complete command is as follows:
1 2 3 4 5 |
./configure --user=www --group=www --prefix=/www/server/nginx --with-openssl=/www/server/nginx/src/openssl --add-module=/www/server/nginx/src/ngx_devel_kit --add-module=/www/server/nginx/src/lua_nginx_module --add-module=/www/server/nginx/src/ngx_cache_purge --add-module=/www/server/nginx/src/nginx-sticky-module --add-module=/www/server/nginx/src/nginx-http-concat --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_image_filter_module --with-http_gzip_static_module --with-http_gunzip_module --with-stream --with-stream_ssl_module --with-ipv6 --with-http_sub_module --with-http_flv_module --with-http_addition_module --with-http_realip_module --with-http_mp4_module --with-ld-opt=-Wl,-E --with-pcre=pcre-8.40 --with-ld-opt=-ljemalloc --add-module=/www/server/nginx/src/ngx_http_geoip2_module <strong>--add-module=/www/server/nginx/src/ngx_brotli</strong> make make install |
3.To add Brotli configuration in Nginx configuration file
In the http{} area
1 2 3 4 5 6 7 8 9 |
http { ... brotli on; brotli_comp_level 6; brotli_buffers 16 8k; brotli_min_length 20; brotli_types *; ... } |
This article was first published by V on 2021-10-09 and can be reprinted with permission, but please be sure to indicate the original link address of the article :http://www.nginxer.com/records/how-to-install-the-brotli-module-for-nginx-on-the-aapanel/