{"id":13530,"date":"2025-02-12T07:00:31","date_gmt":"2025-02-12T07:00:31","guid":{"rendered":"https:\/\/greenwebpage.com\/community\/?p=13530"},"modified":"2025-02-12T07:01:07","modified_gmt":"2025-02-12T07:01:07","slug":"how-to-set-up-nginx-server-blocks-on-ubuntu-24-04","status":"publish","type":"post","link":"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/","title":{"rendered":"How to Set Up Nginx Server Blocks on Ubuntu 24.04"},"content":{"rendered":"\n<p><a href=\"https:\/\/nginx.org\/en\/\">Nginx<\/a> is a leading web server choice renowned for its efficiency, versatility, and stability. By leveraging Nginx&#8217;s ability to handle high-traffic loads and act as a reverse proxy, you can significantly enhance website performance and scalability. We&#8217;ll cover the essential steps, from installing Nginx and organizing website files to configuring server blocks for different domains or subdomains. This guide will walk you through setting up multiple websites on a single Ubuntu 24.04 server using Nginx server blocks.<\/p>\n\n\n\n<p>Let&#8217;s dive into the process of building a robust Nginx web server environment.<\/p>\n\n\n\n<p><a href=\"#Prerequisite:-Installing-Nginx-on-Ubuntu-24.04\">Prerequisite: Installing Nginx on Ubuntu 24.04 <\/a><\/p>\n\n\n\n<p><a href=\"#Setting-Up-Nginx-Server-Blocks-on-Ubuntu-24.04\">Setting Up Nginx Server Blocks on Ubuntu 24.04 <\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Prerequisite:-Installing-Nginx-on-Ubuntu-24.04\"><a id=\"post-13530-_heading=h.gjdgxs\"><\/a>Prerequisite: Installing Nginx on Ubuntu 24.04<\/h2>\n\n\n\n<p>For those running Ubuntu and seeking a robust web server solution, Nginx is an excellent option. Follow these steps to install it:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a id=\"post-13530-_heading=h.30j0zll\"><\/a>Step 1: Update Package Lists<\/h3>\n\n\n\n<p>Start by synchronizing your package lists with the most current repository data:<\/p>\n\n\n\n<pre>sudo apt update<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><a id=\"post-13530-_heading=h.1fob9te\"><\/a>Step 2: Install Nginx<\/h3>\n\n\n\n<p>Nginx can be obtained through the apt package manager by running the appropriate command as superuser if it&#8217;s not already installed on the system:<\/p>\n\n\n\n<pre>sudo apt install nginx<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1128\" height=\"626\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-1.png\" alt=\"sudo apt install nginx\" class=\"wp-image-13531\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-1.png 1128w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-1-300x166.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-1-1024x568.png 1024w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-1-768x426.png 768w\" sizes=\"(max-width: 1128px) 100vw, 1128px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a id=\"post-13530-_heading=h.3znysh7\"><\/a>Step 3: Adjust the Firewall<\/h3>\n\n\n\n<p>To ensure the website is accessible, users need to configure the firewall. It allows traffic to the Nginx web server. If you\u2019re using UFW, you can easily do this.<\/p>\n\n\n\n<p>Nginx offers three primary settings to manage incoming web traffic:<\/p>\n\n\n\n<p><strong>Full Access<\/strong>: Permits both standard (HTTP) and secure (HTTPS) connections on ports 80 and 443, respectively.<\/p>\n\n\n\n<p><strong>HTTP Only<\/strong>: Allows only standard web traffic on port 80.<\/p>\n\n\n\n<p><strong>HTTPS Only<\/strong>: Enables secure web traffic exclusively on port 443.<\/p>\n\n\n\n<p>Choose the setting that best suits your website&#8217;s requirements. To activate your chosen configuration, use the following command:<\/p>\n\n\n\n <pre>sudo ufw allow 'Nginx HTTP'<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1127\" height=\"464\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-2.png\" alt=\"sudo ufw allow 'Nginx HTTP'\" class=\"wp-image-13532\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-2.png 1127w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-2-300x124.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-2-1024x422.png 1024w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-2-768x316.png 768w\" sizes=\"(max-width: 1127px) 100vw, 1127px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>To authenticate the status of the Firewall, users can utilize the \u201c<strong>ufw<\/strong>\u201d tool:<\/p>\n\n\n\n <pre>sudo ufw status<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1121\" height=\"436\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-3.png\" alt=\"sudo ufw status\" class=\"wp-image-13533\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-3.png 1121w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-3-300x117.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-3-1024x398.png 1024w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-3-768x299.png 768w\" sizes=\"(max-width: 1121px) 100vw, 1121px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a id=\"post-13530-_heading=h.2et92p0\"><\/a>Step 4: Managing Nginx (Optional)<\/h3>\n\n\n\n<p>As a widely popular choice for hosting websites, Nginx can be efficiently managed using these commands:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\n<p><strong>Managing Nginx Services<\/strong><\/p>\n<\/th><th>\n<p><strong>Commands<\/strong><\/p>\n<\/th><\/tr><tr><th>\n<p>For Enabling Nginx to Start on the Boot<\/p>\n<\/th><th>\n<p>sudo systemctl enable nginx<\/p>\n<\/th><\/tr><tr><th>\n<p>For Enabling Firewall<\/p>\n<\/th><th>\n<p>sudo ufw enable<\/p>\n<\/th><\/tr><tr><th>\n<p>For Enlisting Installed Applications<\/p>\n<\/th><th>\n<p>sudo ufw app list<\/p>\n<\/th><\/tr><tr><th>\n<p>For Starting the Nginx Service<\/p>\n<\/th><th>\n<p>sudo systemctl start nginx<\/p>\n<\/th><\/tr><tr><th>\n<p>For Stopping Nginx Service<\/p>\n<\/th><th>\n<p>sudo systemctl stop nginx<\/p>\n<\/th><\/tr><tr><th>\n<p>For Restarting the Nginx Service<\/p>\n<\/th><th>\n<p>sudo systemctl restart nginx<\/p>\n<\/th><\/tr><\/thead><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><a id=\"post-13530-_heading=h.tyjcwt\"><\/a>Step 5: Verify the Installation<\/h3>\n\n\n\n<p>To verify Nginx is operational following installation, execute the command:<\/p>\n\n\n\n <pre>sudo systemctl status nginx<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1129\" height=\"682\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-4.png\" alt=\"sudo systemctl status nginx\" class=\"wp-image-13534\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-4.png 1129w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-4-300x181.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-4-1024x619.png 1024w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-4-768x464.png 768w\" sizes=\"(max-width: 1129px) 100vw, 1129px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a id=\"post-13530-_heading=h.3dy6vkm\"><\/a>Step 6: Access Nginx Page<\/h3>\n\n\n\n<p>To access the Nginx web page, users can either input &#8220;<strong>localhost<\/strong>&#8221; or the specific IP address of the <strong>Ubuntu <\/strong>server, which is currently <strong>10.0.2.15<\/strong>:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1072\" height=\"500\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-5.png\" alt=\"Access Nginx\" class=\"wp-image-13535\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-5.png 1072w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-5-300x140.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-5-1024x478.png 1024w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-5-768x358.png 768w\" sizes=\"(max-width: 1072px) 100vw, 1072px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>That is all from the installation of Nginx on Ubuntu 24.04.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Setting-Up-Nginx-Server-Blocks-on-Ubuntu-24.04\"><a id=\"post-13530-_heading=h.1t3h5sf\"><\/a>Setting Up Nginx Server Blocks on Ubuntu 24.04<\/h2>\n\n\n\n<p>Configuring Nginx server blocks on Ubuntu 24.04 is a multi-step process that establishes distinct environments for each hosted domain. Follow these steps to set up your Nginx server blocks:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a id=\"post-13530-_heading=h.4d34og8\"><\/a>Step 1: Create Directory Structure<\/h3>\n\n\n\n<p>Each hosted website requires its own dedicated folder to store its files. For optimal organization, create separate folders within the &#8220;\/<strong>var\/www\/<\/strong>&#8221; directory for each domain.<\/p>\n\n\n\n<p>When setting up Nginx, establish a folder structure under &#8220;\/<strong>var\/www\/<\/strong>&#8221; for your websites. Each domain should have its own &#8220;<strong>html<\/strong>&#8221; subdirectory designated as the document root:<\/p>\n\n\n\n <pre>sudo mkdir -p \/var\/www\/linux.com\/html<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1889\" height=\"209\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-6.png\" alt=\"sudo mkdir -p \/var\/www\/linux.com\/html\" class=\"wp-image-13536\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-6.png 1889w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-6-300x33.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-6-1024x113.png 1024w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-6-768x85.png 768w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-6-1536x170.png 1536w\" sizes=\"(max-width: 1889px) 100vw, 1889px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Important<\/strong>: Users can replace \u201c<strong>linux.com<\/strong>\u201d with the domain name.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a id=\"post-13530-_heading=h.2s8eyo1\"><\/a>Step 2: Assign Ownership<\/h3>\n\n\n\n<p>Assigning ownership of the directory to the Nginx user (usually &#8216;www-data&#8217;) is crucial for avoiding permission-related errors:<\/p>\n\n\n\n <pre>sudo chown -R $USER:$USER \/var\/www\/linux.com\/html<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1896\" height=\"162\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-7.png\" alt=\"sudo chown -R $USER:$USER \/var\/www\/linux.com\/html\" class=\"wp-image-13537\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-7.png 1896w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-7-300x26.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-7-1024x87.png 1024w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-7-768x66.png 768w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-7-1536x131.png 1536w\" sizes=\"(max-width: 1896px) 100vw, 1896px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a id=\"post-13530-_heading=h.17dp8vu\"><\/a>Step 3: Set File Permission<\/h3>\n\n\n\n<p>To set permissions, users should employ the <strong>chmod -R <\/strong>command on the desired path:<\/p>\n\n\n\n <pre>sudo chmod -R 755 \/var\/www\/linux.com<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1898\" height=\"158\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-8.png\" alt=\"sudo chmod -R 755 \/var\/www\/linux.com\" class=\"wp-image-13538\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-8.png 1898w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-8-300x25.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-8-1024x85.png 1024w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-8-768x64.png 768w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-8-1536x128.png 1536w\" sizes=\"(max-width: 1898px) 100vw, 1898px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a id=\"post-13530-_heading=h.3rdcrjn\"><\/a>Step 4: Create an HTML file<\/h3>\n\n\n\n<p>Once file permissions are set, create an HTML page (e.g., &#8220;<strong>index.html<\/strong>&#8220;) in the &#8220;\/<strong>var\/www\/linux.com\/html\/<\/strong>&#8221; directory:<\/p>\n\n\n\n <pre>sudo nano \/var\/www\/linux.com\/html\/index.html<\/pre>\n\n\n\n<p>Users need to paste the HTML code in the configuration file:<\/p>\n\n\n\n <pre>&lt;!DOCTYPE html&gt; <br>&lt;html lang=\"en\" dir=\"ltr\"&gt; <br>&lt;head&gt; <br>&lt;meta charset=\"utf-8\"&gt; <br>&lt;title&gt;Linux empowers the Ubuntu Users&lt;\/title&gt; <br>&lt;\/head&gt; <br>&lt;body&gt; <br>&lt;h1&gt; Setting Up Nginx Server Blocks on Ubuntu 24.04 &lt;\/h1&gt; <br>&lt;\/body&gt; <br>&lt;\/html&gt;<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1901\" height=\"838\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-9.png\" alt=\"Paste html code in configuration file\" class=\"wp-image-13539\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-9.png 1901w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-9-300x132.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-9-1024x451.png 1024w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-9-768x339.png 768w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-9-1536x677.png 1536w\" sizes=\"(max-width: 1901px) 100vw, 1901px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>In the end, save and exit the file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a id=\"post-13530-_heading=h.26in1rg\"><\/a>Step 5: Create Server Blocks<\/h3>\n\n\n\n<p>Just like Apache&#8217;s virtual hosts, Nginx employs server blocks to define specific settings for different domains or subdomains hosted on the same server:<\/p>\n\n\n\n <pre>sudo nano \/etc\/nginx\/sites-available\/linux.com<\/pre>\n\n\n\n<p>This script configures your web server to handle requests for the website &#8220;linux.com&#8221;. It listens on the standard port 80 and delivers files from the directory you specify:<\/p>\n\n\n\n <pre>server {<\/pre>\n<pre>listen 80;<\/pre>\n<pre>listen [::]:80;<\/pre>\n<pre>root \/var\/www\/linux.com\/html;<\/pre>\n<pre>index index.html index.htm index.nginx-debian.html;<\/pre>\n<pre>server_name linux.com www.linux.com;<\/pre>\n<pre>location \/ {<\/pre>\n<pre>try_files $uri $uri\/ =404;<\/pre>\n<pre>}<\/pre>\n<pre>}<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1891\" height=\"849\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-10.png\" alt=\"Create blocks in Nginx configuration file\" class=\"wp-image-13540\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-10.png 1891w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-10-300x135.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-10-1024x460.png 1024w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-10-768x345.png 768w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-10-1536x690.png 1536w\" sizes=\"(max-width: 1891px) 100vw, 1891px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>So, save and exit the configuration file.<\/p>\n\n\n\n<p><strong>Note<\/strong>: These configuration files define the specific settings for each domain, such as the server&#8217;s identity, primary content directory, and paths to access and error logs.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a id=\"post-13530-_heading=h.lnxbz9\"><\/a>Step 6: Enable Server Blocks<\/h3>\n\n\n\n<p>After creating server block configurations, users need to enable them by linking the files to the <strong>&#8216;sites-enabled<\/strong>&#8216; folder:<\/p>\n\n\n\n <pre>sudo ln -s \/etc\/nginx\/sites-available\/linux.com \/etc\/nginx\/sites-enabled\/<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1891\" height=\"205\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-11.png\" alt=\"sudo ln -s \/etc\/nginx\/sites-available\/linux.com \/etc\/nginx\/sites-enabled\" class=\"wp-image-13541\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-11.png 1891w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-11-300x33.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-11-1024x111.png 1024w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-11-768x83.png 768w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-11-1536x167.png 1536w\" sizes=\"(max-width: 1891px) 100vw, 1891px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Important<\/strong>: Users can perform this step for each server block.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a id=\"post-13530-_heading=h.35nkun2\"><\/a>Step 7: Test and Restart Nginx<\/h3>\n\n\n\n<p>To prevent potential issues, it&#8217;s crucial to check the recently modified Nginx configuration for accuracy before initiating the service. This can be easily accomplished by executing the &#8216;nginx -t&#8217; command:<\/p>\n\n\n\n <pre>sudo nginx -t<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1123\" height=\"158\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-12.png\" alt=\"sudo nginx -t\" class=\"wp-image-13542\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-12.png 1123w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-12-300x42.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-12-1024x144.png 1024w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-12-768x108.png 768w\" sizes=\"(max-width: 1123px) 100vw, 1123px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a id=\"post-13530-_heading=h.1ksv4uv\"><\/a>Step 8: Restart Nginx<\/h3>\n\n\n\n<p>Now, the configuration changes can be activated by restarting Nginx with the <strong>&#8216;systemctl&#8217; <\/strong>command:<\/p>\n\n\n\n <pre>sudo systemctl restart nginx<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1123\" height=\"90\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-13.png\" alt=\"sudo systemctl restart nginx\" class=\"wp-image-13543\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-13.png 1123w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-13-300x24.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-13-1024x82.png 1024w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-13-768x62.png 768w\" sizes=\"(max-width: 1123px) 100vw, 1123px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Note<\/strong>: To access your Nginx server, your firewall must be configured to permit incoming connections on ports 80 for HTTP and 443 for HTTPS.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a id=\"post-13530-_heading=h.44sinio\"><\/a>Step 9: Verify Nginx Setup<\/h3>\n\n\n\n<p>To complete the process, ensure your websites are accessible by opening a web browser and entering <strong>localhost\/domain_names\/IP_address<\/strong> in the address bar:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1090\" height=\"278\" src=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-14.png\" alt=\"Verify Nginx setup\" class=\"wp-image-13544\" srcset=\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-14.png 1090w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-14-300x77.png 300w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-14-1024x261.png 1024w, https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/word-image-13530-14-768x196.png 768w\" sizes=\"(max-width: 1090px) 100vw, 1090px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>In this way, Nginx server blocks have been set up on the Ubuntu 24.04 server.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a id=\"post-13530-_heading=h.2jxsxqh\"><\/a>Conclusion<\/h2>\n\n\n\n<p>Configuring Nginx server blocks on Ubuntu involves several essential steps. Begin by establishing dedicated directories within <strong>\/var\/www<\/strong> for each website, ensuring proper permissions. Next, craft detailed server block configurations within the <strong>\/etc\/nginx\/sites-available <\/strong>directory, outlining how Nginx should handle requests for each domain.<\/p>\n\n\n\n<p>To activate these configurations, create symbolic links in the <strong>\/etc\/nginx\/sites-enabled <\/strong>folder. Before deploying changes, it&#8217;s crucial to thoroughly test the configuration for errors to guarantee optimal performance.<\/p>\n\n\n\t\t\t\t\t\t\t<h3 style=\"margin-bottom:20px;display:block;width:100%;margin-top:10px\">Frequently Asked Questions <\/h3>\r\n\t\t\t\t\t\t<style>\r\n\t\t\t\t<style>\r\n#wpsm_accordion_13546 .wpsm_panel-heading{\r\n\tpadding:0px !important;\r\n}\r\n#wpsm_accordion_13546 .wpsm_panel-title {\r\n\tmargin:0px !important; \r\n\ttext-transform:none !important;\r\n\tline-height: 1 !important;\r\n}\r\n#wpsm_accordion_13546 .wpsm_panel-title a{\r\n\ttext-decoration:none;\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\tpadding:0px;\r\n\tfont-size: 18px !important;\r\n\tfont-family: Open Sans !important;\r\n\tcolor:#000000 !important;\r\n\tborder-bottom:0px !important;\r\n}\r\n\r\n#wpsm_accordion_13546 .wpsm_panel-title a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#wpsm_accordion_13546 .wpsm_panel-title a:hover, #wpsm_accordion_13546 .wpsm_panel-title a:focus {\r\n\tcolor:#000000 !important;\r\n}\r\n#wpsm_accordion_13546 .acc-a{\r\n\tcolor: #000000 !important;\r\n\tbackground-color:#e8e8e8 !important;\r\n\tborder-color: #ddd;\r\n}\r\n#wpsm_accordion_13546 .wpsm_panel-default > .wpsm_panel-heading{\r\n\tcolor: #000000 !important;\r\n\tbackground-color: #e8e8e8 !important;\r\n\tborder-color: #e8e8e8 !important;\r\n\tborder-top-left-radius: 0px;\r\n\tborder-top-right-radius: 0px;\r\n}\r\n#wpsm_accordion_13546 .wpsm_panel-default {\r\n\t\tborder:1px solid transparent !important;\r\n\t}\r\n#wpsm_accordion_13546 {\r\n\tmargin-bottom: 20px;\r\n\toverflow: hidden;\r\n\tfloat: none;\r\n\twidth: 100%;\r\n\tdisplay: block;\r\n}\r\n#wpsm_accordion_13546 .ac_title_class{\r\n\tdisplay: block;\r\n\tpadding-top: 12px;\r\n\tpadding-bottom: 12px;\r\n\tpadding-left: 15px;\r\n\tpadding-right: 15px;\r\n}\r\n#wpsm_accordion_13546  .wpsm_panel {\r\n\toverflow:hidden;\r\n\t-webkit-box-shadow: 0 0px 0px rgba(0, 0, 0, .05);\r\n\tbox-shadow: 0 0px 0px rgba(0, 0, 0, .05);\r\n\t\tborder-radius: 4px;\r\n\t}\r\n#wpsm_accordion_13546  .wpsm_panel + .wpsm_panel {\r\n\t\tmargin-top: 5px;\r\n\t}\r\n#wpsm_accordion_13546  .wpsm_panel-body{\r\n\tbackground-color:#ffffff !important;\r\n\tcolor:#000000 !important;\r\n\tborder-top-color: #e8e8e8 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\toverflow: hidden;\r\n\t\tborder: 2px solid #e8e8e8 !important;\r\n\t}\r\n\r\n#wpsm_accordion_13546 .ac_open_cl_icon{\r\n\tbackground-color:#e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tfloat:right !important;\r\n\tpadding-top: 12px !important;\r\n\tpadding-bottom: 12px !important;\r\n\tline-height: 1.0 !important;\r\n\tpadding-left: 15px !important;\r\n\tpadding-right: 15px !important;\r\n\tdisplay: inline-block !important;\r\n}\r\n\r\n\t\t\t\r\n\t\t\t<\/style>\t\r\n\t\t\t<\/style>\r\n\t\t\t<div class=\"wpsm_panel-group\" id=\"wpsm_accordion_13546\" >\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t<!-- Inner panel Start -->\r\n\t\t\t\t\t<div class=\"wpsm_panel wpsm_panel-default\">\r\n\t\t\t\t\t\t<div class=\"wpsm_panel-heading\" role=\"tab\" >\r\n\t\t\t\t\t\t  <h4 class=\"wpsm_panel-title\">\r\n\t\t\t\t\t\t\t<a  class=\"\"  data-toggle=\"collapse\" data-parent=\"#wpsm_accordion_13546 \" href=\"javascript:void(0)\" data-target=\"#ac_13546_collapse1\" onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"ac_open_cl_icon fa fa-plus\"><\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t<span class=\"ac_title_class\">\r\n\t\t\t\t\t\t\t\t\tWhat are Nginx server blocks?\t\t\t\t\t\t\t\t<\/span>\r\n\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t  <\/h4>\r\n\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t\t<div id=\"ac_13546_collapse1\" class=\"wpsm_panel-collapse collapse \"  >\r\n\t\t\t\t\t\t  <div class=\"wpsm_panel-body\">\r\n\t\t\t\t\t\t\tNginx server blocks, also known as virtual hosts, allow you to host multiple websites on a single server by creating separate configurations for each site.\t\t\t\t\t\t  <\/div>\r\n\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<!-- Inner panel End -->\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t<!-- Inner panel Start -->\r\n\t\t\t\t\t<div class=\"wpsm_panel wpsm_panel-default\">\r\n\t\t\t\t\t\t<div class=\"wpsm_panel-heading\" role=\"tab\" >\r\n\t\t\t\t\t\t  <h4 class=\"wpsm_panel-title\">\r\n\t\t\t\t\t\t\t<a  class=\"collapsed\"  data-toggle=\"collapse\" data-parent=\"#wpsm_accordion_13546 \" href=\"javascript:void(0)\" data-target=\"#ac_13546_collapse2\" onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"ac_open_cl_icon fa fa-plus\"><\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t<span class=\"ac_title_class\">\r\n\t\t\t\t\t\t\t\t\tHow do I install Nginx on Ubuntu 24.04?\t\t\t\t\t\t\t\t<\/span>\r\n\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t  <\/h4>\r\n\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t\t<div id=\"ac_13546_collapse2\" class=\"wpsm_panel-collapse collapse \"  >\r\n\t\t\t\t\t\t  <div class=\"wpsm_panel-body\">\r\n\t\t\t\t\t\t\tTo install Nginx, run <code>sudo apt update<\/code> and then <code>sudo apt install nginx<\/code>. Once installed, Nginx can be started with <code>sudo systemctl start nginx<\/code>.\t\t\t\t\t\t  <\/div>\r\n\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<!-- Inner panel End -->\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t<!-- Inner panel Start -->\r\n\t\t\t\t\t<div class=\"wpsm_panel wpsm_panel-default\">\r\n\t\t\t\t\t\t<div class=\"wpsm_panel-heading\" role=\"tab\" >\r\n\t\t\t\t\t\t  <h4 class=\"wpsm_panel-title\">\r\n\t\t\t\t\t\t\t<a  class=\"collapsed\"  data-toggle=\"collapse\" data-parent=\"#wpsm_accordion_13546 \" href=\"javascript:void(0)\" data-target=\"#ac_13546_collapse3\" onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"ac_open_cl_icon fa fa-plus\"><\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t<span class=\"ac_title_class\">\r\n\t\t\t\t\t\t\t\t\tHow do I create a new server block?\t\t\t\t\t\t\t\t<\/span>\r\n\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t  <\/h4>\r\n\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t\t<div id=\"ac_13546_collapse3\" class=\"wpsm_panel-collapse collapse \"  >\r\n\t\t\t\t\t\t  <div class=\"wpsm_panel-body\">\r\n\t\t\t\t\t\t\tCreate a new configuration file in the <code>\/etc\/nginx\/sites-available\/<\/code> directory and then create a symbolic link in <code>\/etc\/nginx\/sites-enabled\/<\/code> to activate it.\t\t\t\t\t\t  <\/div>\r\n\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<!-- Inner panel End -->\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t<!-- Inner panel Start -->\r\n\t\t\t\t\t<div class=\"wpsm_panel wpsm_panel-default\">\r\n\t\t\t\t\t\t<div class=\"wpsm_panel-heading\" role=\"tab\" >\r\n\t\t\t\t\t\t  <h4 class=\"wpsm_panel-title\">\r\n\t\t\t\t\t\t\t<a  class=\"collapsed\"  data-toggle=\"collapse\" data-parent=\"#wpsm_accordion_13546 \" href=\"javascript:void(0)\" data-target=\"#ac_13546_collapse4\" onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"ac_open_cl_icon fa fa-plus\"><\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t<span class=\"ac_title_class\">\r\n\t\t\t\t\t\t\t\t\tHow do I configure a server block for a domain?\t\t\t\t\t\t\t\t<\/span>\r\n\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t  <\/h4>\r\n\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t\t<div id=\"ac_13546_collapse4\" class=\"wpsm_panel-collapse collapse \"  >\r\n\t\t\t\t\t\t  <div class=\"wpsm_panel-body\">\r\n\t\t\t\t\t\t\tEdit the configuration file for your domain in <code>\/etc\/nginx\/sites-available\/yourdomain.com<\/code> with the correct server name, root directory, and other settings, then create a symbolic link in <code>sites-enabled<\/code>.\t\t\t\t\t\t  <\/div>\r\n\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<!-- Inner panel End -->\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t<!-- Inner panel Start -->\r\n\t\t\t\t\t<div class=\"wpsm_panel wpsm_panel-default\">\r\n\t\t\t\t\t\t<div class=\"wpsm_panel-heading\" role=\"tab\" >\r\n\t\t\t\t\t\t  <h4 class=\"wpsm_panel-title\">\r\n\t\t\t\t\t\t\t<a  class=\"collapsed\"  data-toggle=\"collapse\" data-parent=\"#wpsm_accordion_13546 \" href=\"javascript:void(0)\" data-target=\"#ac_13546_collapse5\" onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"ac_open_cl_icon fa fa-plus\"><\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t<span class=\"ac_title_class\">\r\n\t\t\t\t\t\t\t\t\tHow do I test the Nginx configuration?\t\t\t\t\t\t\t\t<\/span>\r\n\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t  <\/h4>\r\n\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t\t<div id=\"ac_13546_collapse5\" class=\"wpsm_panel-collapse collapse \"  >\r\n\t\t\t\t\t\t  <div class=\"wpsm_panel-body\">\r\n\t\t\t\t\t\t\tRun <code>sudo nginx -t<\/code> to check for syntax errors in the configuration files before reloading Nginx.\t\t\t\t\t\t  <\/div>\r\n\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<!-- Inner panel End -->\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\t<\/div>\r\n\t\t\t\r\n<script type=\"text\/javascript\">\r\n\t\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.wpsm_panel .wpsm_panel-body iframe' ).width();\r\n\t\t\tvar height=jQuery( '.wpsm_panel .wpsm_panel-body iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\t\t\r\n<\/script>\t\n\n\n\n<p><\/p>\n\n    <div class=\"xs_social_share_widget xs_share_url after_content \t\tmain_content  wslu-style-1 wslu-share-box-shaped wslu-fill-colored wslu-none wslu-share-horizontal wslu-theme-font-no wslu-main_content\">\n\n\t\t\n        <ul>\n\t\t\t        <\/ul>\n    <\/div> \n","protected":false},"excerpt":{"rendered":"<p>Nginx is a leading web server choice renowned for its efficiency, versatility, and stability. By leveraging Nginx&#8217;s ability to handle high-traffic loads and act as a reverse proxy, you can significantly enhance website performance and scalability. We&#8217;ll cover the essential steps, from installing Nginx and organizing website files to configuring server blocks for different domains [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":13549,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[229,317,274,280],"class_list":["post-13530","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-nginx","tag-ubuntu-24-04","tag-web-hosting","tag-web-server"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Set Up Nginx Server Blocks on Ubuntu 24.04 - Greenwebpage Community<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Set Up Nginx Server Blocks on Ubuntu 24.04 - Greenwebpage Community\" \/>\n<meta property=\"og:description\" content=\"Nginx is a leading web server choice renowned for its efficiency, versatility, and stability. By leveraging Nginx&#8217;s ability to handle high-traffic loads and act as a reverse proxy, you can significantly enhance website performance and scalability. We&#8217;ll cover the essential steps, from installing Nginx and organizing website files to configuring server blocks for different domains [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/\" \/>\n<meta property=\"og:site_name\" content=\"Greenwebpage Community\" \/>\n<meta property=\"article:published_time\" content=\"2025-02-12T07:00:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-02-12T07:01:07+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/Set-up-Nginx-server-blocks-on-Ubuntu-24.04.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"1020\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Karim Buzdar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Karim Buzdar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/\"},\"author\":{\"name\":\"Karim Buzdar\",\"@id\":\"https:\/\/greenwebpage.com\/community\/#\/schema\/person\/467c100c1d017bc081473ee0440680c8\"},\"headline\":\"How to Set Up Nginx Server Blocks on Ubuntu 24.04\",\"datePublished\":\"2025-02-12T07:00:31+00:00\",\"dateModified\":\"2025-02-12T07:01:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/\"},\"wordCount\":923,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/greenwebpage.com\/community\/#organization\"},\"image\":{\"@id\":\"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/Set-up-Nginx-server-blocks-on-Ubuntu-24.04.jpeg\",\"keywords\":[\"Nginx\",\"Ubuntu 24.04\",\"Web Hosting\",\"Web Server\"],\"articleSection\":[\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/\",\"url\":\"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/\",\"name\":\"How to Set Up Nginx Server Blocks on Ubuntu 24.04 - Greenwebpage Community\",\"isPartOf\":{\"@id\":\"https:\/\/greenwebpage.com\/community\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/Set-up-Nginx-server-blocks-on-Ubuntu-24.04.jpeg\",\"datePublished\":\"2025-02-12T07:00:31+00:00\",\"dateModified\":\"2025-02-12T07:01:07+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/#primaryimage\",\"url\":\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/Set-up-Nginx-server-blocks-on-Ubuntu-24.04.jpeg\",\"contentUrl\":\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/Set-up-Nginx-server-blocks-on-Ubuntu-24.04.jpeg\",\"width\":1020,\"height\":600,\"caption\":\"Set up Nginx server blocks on Ubuntu 24.04\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/greenwebpage.com\/community\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Set Up Nginx Server Blocks on Ubuntu 24.04\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/greenwebpage.com\/community\/#website\",\"url\":\"https:\/\/greenwebpage.com\/community\/\",\"name\":\"Greenwebpage Community\",\"description\":\"Get online in three steps with our wide range of web hosting solutions. Choose from professional business to enterprise options designed to meet your needs.\",\"publisher\":{\"@id\":\"https:\/\/greenwebpage.com\/community\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/greenwebpage.com\/community\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/greenwebpage.com\/community\/#organization\",\"name\":\"Greenwebpage Community\",\"url\":\"https:\/\/greenwebpage.com\/community\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/greenwebpage.com\/community\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2023\/10\/cropped-logomic.png\",\"contentUrl\":\"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2023\/10\/cropped-logomic.png\",\"width\":512,\"height\":512,\"caption\":\"Greenwebpage Community\"},\"image\":{\"@id\":\"https:\/\/greenwebpage.com\/community\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/greenwebpage.com\/community\/#\/schema\/person\/467c100c1d017bc081473ee0440680c8\",\"name\":\"Karim Buzdar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/greenwebpage.com\/community\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/0628fcbcddd9bc5486245d2cf4a904dbcdeac9ad6c3098f49237094e9d513d0c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/0628fcbcddd9bc5486245d2cf4a904dbcdeac9ad6c3098f49237094e9d513d0c?s=96&d=mm&r=g\",\"caption\":\"Karim Buzdar\"},\"sameAs\":[\"https:\/\/greenwebpage.com\"],\"url\":\"https:\/\/greenwebpage.com\/community\/author\/karim\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Set Up Nginx Server Blocks on Ubuntu 24.04 - Greenwebpage Community","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/","og_locale":"en_US","og_type":"article","og_title":"How to Set Up Nginx Server Blocks on Ubuntu 24.04 - Greenwebpage Community","og_description":"Nginx is a leading web server choice renowned for its efficiency, versatility, and stability. By leveraging Nginx&#8217;s ability to handle high-traffic loads and act as a reverse proxy, you can significantly enhance website performance and scalability. We&#8217;ll cover the essential steps, from installing Nginx and organizing website files to configuring server blocks for different domains [&hellip;]","og_url":"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/","og_site_name":"Greenwebpage Community","article_published_time":"2025-02-12T07:00:31+00:00","article_modified_time":"2025-02-12T07:01:07+00:00","og_image":[{"width":1020,"height":600,"url":"http:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/Set-up-Nginx-server-blocks-on-Ubuntu-24.04.jpeg","type":"image\/jpeg"}],"author":"Karim Buzdar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Karim Buzdar","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/#article","isPartOf":{"@id":"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/"},"author":{"name":"Karim Buzdar","@id":"https:\/\/greenwebpage.com\/community\/#\/schema\/person\/467c100c1d017bc081473ee0440680c8"},"headline":"How to Set Up Nginx Server Blocks on Ubuntu 24.04","datePublished":"2025-02-12T07:00:31+00:00","dateModified":"2025-02-12T07:01:07+00:00","mainEntityOfPage":{"@id":"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/"},"wordCount":923,"commentCount":0,"publisher":{"@id":"https:\/\/greenwebpage.com\/community\/#organization"},"image":{"@id":"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/#primaryimage"},"thumbnailUrl":"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/Set-up-Nginx-server-blocks-on-Ubuntu-24.04.jpeg","keywords":["Nginx","Ubuntu 24.04","Web Hosting","Web Server"],"articleSection":["Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/","url":"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/","name":"How to Set Up Nginx Server Blocks on Ubuntu 24.04 - Greenwebpage Community","isPartOf":{"@id":"https:\/\/greenwebpage.com\/community\/#website"},"primaryImageOfPage":{"@id":"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/#primaryimage"},"image":{"@id":"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/#primaryimage"},"thumbnailUrl":"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/Set-up-Nginx-server-blocks-on-Ubuntu-24.04.jpeg","datePublished":"2025-02-12T07:00:31+00:00","dateModified":"2025-02-12T07:01:07+00:00","breadcrumb":{"@id":"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/#primaryimage","url":"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/Set-up-Nginx-server-blocks-on-Ubuntu-24.04.jpeg","contentUrl":"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2025\/02\/Set-up-Nginx-server-blocks-on-Ubuntu-24.04.jpeg","width":1020,"height":600,"caption":"Set up Nginx server blocks on Ubuntu 24.04"},{"@type":"BreadcrumbList","@id":"https:\/\/greenwebpage.com\/community\/how-to-set-up-nginx-server-blocks-on-ubuntu-24-04\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/greenwebpage.com\/community\/"},{"@type":"ListItem","position":2,"name":"How to Set Up Nginx Server Blocks on Ubuntu 24.04"}]},{"@type":"WebSite","@id":"https:\/\/greenwebpage.com\/community\/#website","url":"https:\/\/greenwebpage.com\/community\/","name":"Greenwebpage Community","description":"Get online in three steps with our wide range of web hosting solutions. Choose from professional business to enterprise options designed to meet your needs.","publisher":{"@id":"https:\/\/greenwebpage.com\/community\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/greenwebpage.com\/community\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/greenwebpage.com\/community\/#organization","name":"Greenwebpage Community","url":"https:\/\/greenwebpage.com\/community\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/greenwebpage.com\/community\/#\/schema\/logo\/image\/","url":"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2023\/10\/cropped-logomic.png","contentUrl":"https:\/\/greenwebpage.com\/community\/wp-content\/uploads\/2023\/10\/cropped-logomic.png","width":512,"height":512,"caption":"Greenwebpage Community"},"image":{"@id":"https:\/\/greenwebpage.com\/community\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/greenwebpage.com\/community\/#\/schema\/person\/467c100c1d017bc081473ee0440680c8","name":"Karim Buzdar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/greenwebpage.com\/community\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/0628fcbcddd9bc5486245d2cf4a904dbcdeac9ad6c3098f49237094e9d513d0c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0628fcbcddd9bc5486245d2cf4a904dbcdeac9ad6c3098f49237094e9d513d0c?s=96&d=mm&r=g","caption":"Karim Buzdar"},"sameAs":["https:\/\/greenwebpage.com"],"url":"https:\/\/greenwebpage.com\/community\/author\/karim\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/greenwebpage.com\/community\/wp-json\/wp\/v2\/posts\/13530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/greenwebpage.com\/community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/greenwebpage.com\/community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/greenwebpage.com\/community\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/greenwebpage.com\/community\/wp-json\/wp\/v2\/comments?post=13530"}],"version-history":[{"count":3,"href":"https:\/\/greenwebpage.com\/community\/wp-json\/wp\/v2\/posts\/13530\/revisions"}],"predecessor-version":[{"id":13548,"href":"https:\/\/greenwebpage.com\/community\/wp-json\/wp\/v2\/posts\/13530\/revisions\/13548"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/greenwebpage.com\/community\/wp-json\/wp\/v2\/media\/13549"}],"wp:attachment":[{"href":"https:\/\/greenwebpage.com\/community\/wp-json\/wp\/v2\/media?parent=13530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/greenwebpage.com\/community\/wp-json\/wp\/v2\/categories?post=13530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/greenwebpage.com\/community\/wp-json\/wp\/v2\/tags?post=13530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}