{"id":3123,"date":"2024-10-22T04:46:57","date_gmt":"2025-02-23T21:58:23","guid":{"rendered":""},"modified":"2025-02-02T00:46:19","modified_gmt":"2025-02-01T23:46:19","slug":"how-to-install-nginx-with-brotli-compression-on-ubuntu-20-04","status":"publish","type":"post","link":"https:\/\/netcloud24.com\/knowledgebase\/how-to-install-nginx-with-brotli-compression-on-ubuntu-20-04\/","title":{"rendered":"Linux VPS &#038; VPS Windows Setup Guide | NetCloud24 Nginx with Brotli Compression on Ubuntu 20.04"},"content":{"rendered":"<p>\u00a0<\/p>\n<\/p>\n<header>\n<h1>\u00a0<\/h1>\n<\/header>\n<article>\n<p>Nginx is a popular web server known for its performance and scalability. Adding Brotli compression to Nginx can help reduce the size of your website files, improving load times for users. In this guide, we&#8217;ll walk you through the process of installing Nginx with Brotli compression on Ubuntu 20.04. Additionally, we&#8217;ll cover how to use <strong>rsync<\/strong> to mirror your website across multiple servers. If you&#8217;re considering hosting options, a <a href=\"https:\/\/ie.netcloud24.com\">Windows VPS <\/a> might be a great solution for your needs.<\/p>\n<section>\n<h2>Step 1: Update Your System<\/h2>\n<p>Before installing any new software, it\u2019s important to make sure your system is up-to-date. Run the following commands to update your system:<\/p>\n<pre><code>sudo apt update &amp;&amp; sudo apt upgrade<\/code><\/pre>\n<p>This ensures that your server is running the latest packages and security updates. Whether you are using a local server or a <a href=\"https:\/\/ie.netcloud24.com\">UK Windows VPS<\/a>, keeping your system updated is essential.<\/p>\n<\/section>\n<section>\n<h2>Step 2: Install Nginx<\/h2>\n<p>Install Nginx using the package manager with the following command:<\/p>\n<pre><code>sudo apt install nginx<\/code><\/pre>\n<p>Once installed, you can start and enable Nginx to run at boot:<\/p>\n<pre><code>\r\nsudo systemctl start nginx\r\nsudo systemctl enable nginx\r\n            <\/code><\/pre>\n<p>Nginx should now be up and running. You can verify this by navigating to <code>http:\/\/your-server-ip<\/code> in a browser. This setup works for both local environments and <a href=\"https:\/\/ie.netcloud24.com\">Windows VPSVirtual Private Server hosting<\/a>.<\/p>\n<\/section>\n<section>\n<h2>Step 3: Install Brotli Module for Nginx<\/h2>\n<p>Brotli is a compression algorithm that can significantly reduce the size of your static files. To enable Brotli in Nginx, you first need to install the required modules. Start by installing the dependencies:<\/p>\n<pre><code>sudo apt install git gcc make zlib1g-dev libpcre3 libpcre3-dev<\/code><\/pre>\n<p>Next, download and compile the Brotli module:<\/p>\n<pre><code>\r\ncd \/usr\/local\/src\r\nsudo git clone https:\/\/github.com\/google\/ngx_brotli.git\r\ncd ngx_brotli\r\nsudo git submodule update --init --recursive\r\n            <\/code><\/pre>\n<p>Now recompile Nginx with Brotli support:<\/p>\n<pre><code>\r\ncd \/usr\/local\/src\r\nsudo apt-get source nginx\r\ncd nginx-*\r\nsudo .\/configure --add-module=\/usr\/local\/src\/ngx_brotli\r\nsudo make\r\nsudo make install\r\n            <\/code><\/pre>\n<\/section>\n<section>\n<h2>Step 4: Enable Brotli in Nginx<\/h2>\n<p>After installing the Brotli module, you need to enable it in your Nginx configuration. Open the Nginx configuration file:<\/p>\n<pre><code>sudo nano \/etc\/nginx\/nginx.conf<\/code><\/pre>\n<p>Add the following Brotli settings within the <code>http<\/code> block:<\/p>\n<pre><code>\r\nbrotli on;\r\nbrotli_comp_level 6;\r\nbrotli_types text\/plain text\/css application\/json application\/javascript text\/xml application\/xml application\/xml+rss text\/javascript;\r\n            <\/code><\/pre>\n<p>Save and exit the file, then restart Nginx to apply the changes:<\/p>\n<pre><code>sudo systemctl restart nginx<\/code><\/pre>\n<p>Brotli compression is now enabled. This improves your website&#8217;s performance, especially when hosted on platforms like <a href=\"https:\/\/ie.netcloud24.com\">Windows VPS hosting UK<\/a>.<\/p>\n<\/section>\n<section>\n<h2>Step 5: Mirror Your Website with rsync<\/h2>\n<p>To ensure that your website is available across multiple servers, you can use <strong>rsync<\/strong> to mirror your website&#8217;s files. This is particularly useful if you&#8217;re running multiple <a href=\"https:\/\/ie.netcloud24.com\">VPS Windows VPS Servers<\/a> or want to maintain backups.<\/p>\n<p>Use the following command to sync your website files to a remote server:<\/p>\n<pre><code>rsync -avz \/var\/www\/html\/ user@remote-server:\/var\/www\/html\/<\/code><\/pre>\n<p>This command synchronizes your website\u2019s files from the local server to a remote server, ensuring that both servers have the same content. Automating this with cron can help ensure your data is always up-to-date.<\/p>\n<\/section>\n<section>\n<h2>Step 6: Test Brotli Compression<\/h2>\n<p>After setting up Brotli, you should test whether the compression is working correctly. You can do this using an online Brotli checker or by running the following <code>curl<\/code> command:<\/p>\n<pre><code>curl -H \"Accept-Encoding: br\" -I http:\/\/your-server-ip<\/code><\/pre>\n<p>If Brotli is working, you should see <code>content-encoding: br<\/code> in the response headers.<\/p>\n<\/section>\n<\/article>\n<footer>\n<p>By using Nginx with Brotli compression, you can significantly improve your website\u2019s loading times. If you&#8217;re looking for a reliable hosting platform, check out <a href=\"https:\/\/ie.netcloud24.com\">Windows VPS <\/a>. Their solutions include <strong>virtual private server hosting windows<\/strong>, <strong>windows vps hosting uk<\/strong>, and <strong>windows virtual private server hosting<\/strong>, all designed to help your website perform at its best.<\/p>\n<\/footer>\n<div class=\"post-author-box\" style=\"border-top:1px solid #ddd;margin-top:20px;padding-top:15px;\">\n<p><strong>Author:<\/strong> \u0141ukasz Bodziony<\/p>\n<p><strong>Website:<\/strong> <a href=\"https:\/\/ca.netcloud24.com\" target=\"_blank\" rel=\"dofollow\">Windows VPS<\/a><\/p>\n<p><em>\u0141ukasz Bodziony is the CEO and founder of <a href=\"https:\/\/netcloud24.com\" target=\"_blank\" rel=\"dofollow\">NETCLOUD24<\/a>, a global VPS hosting brand proudly originating from Poland. With extensive experience in cloud computing, virtualization, and server management, he delivers high-performance <strong>Windows VPS<\/strong> and <strong>Remote Desktop Services (RDS)<\/strong> solutions to clients across Europe, North America, and beyond.<\/em><\/p>\n<p><em>His expertise covers a wide range of technologies, including <strong>Microsoft Azure<\/strong>, <strong>Proxmox VE<\/strong>, <strong>Amazon Web Services (AWS)<\/strong>, and numerous other virtualization and cloud platforms.<\/em><\/p>\n<p><em>Beyond running his hosting business, \u0141ukasz also provides <strong>professional paid server configuration and optimization services<\/strong> for companies and individuals. Outside of work, he is dedicated to caring for his children and building a secure future for them.<\/em><\/p>\n<p><em>If you are interested in working with him or need expert assistance with your hosting, cloud environment, or server setup, feel free to reach out via <a href=\"https:\/\/ca.netcloud24.com\" target=\"_blank\" rel=\"dofollow\">Windows VPS<\/a>.<\/em><\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0 \u00a0 Nginx is a popular web server known for its performance and scalability. Adding Brotli compression to Nginx can help reduce the size of your website files,\u2026<\/p>\n","protected":false},"author":1,"featured_media":3421,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[],"tags":[14,12,11,23,20,21,22,17,7,8,6,10,18,19,15,24,16,5,13,9],"class_list":["post-3123","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","tag-cheapvps","tag-cloudvps","tag-hostingvps","tag-rds","tag-rdscal","tag-remotedesktop","tag-remotedesktopvps","tag-servervps","tag-ukvps","tag-virtualserver","tag-vpshosting","tag-vpsserver","tag-vpssolutions","tag-vpswindows","tag-vpswithwindows","tag-windowsrds","tag-windowsserver","tag-windowsvps","tag-windowsvpshosting","tag-windowsvpsuk"],"jetpack_publicize_connections":[],"_links":{"self":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/3123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=3123"}],"version-history":[{"count":0,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/3123\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/media\/3421"}],"wp:attachment":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/media?parent=3123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=3123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=3123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}