{"id":1169,"date":"2023-06-12T07:03:09","date_gmt":"2023-06-12T07:03:09","guid":{"rendered":"https:\/\/www.dedicatedcore.com\/blog\/?p=1169"},"modified":"2024-08-28T12:15:28","modified_gmt":"2024-08-28T12:15:28","slug":"how-to-install-nginx-on-ubuntu","status":"publish","type":"post","link":"https:\/\/www.dedicatedcore.com\/blog\/how-to-install-nginx-on-ubuntu\/","title":{"rendered":"How to Install Nginx on Ubuntu 20.04"},"content":{"rendered":"<p>One common option for hosting websites and controlling online traffic is Nginx. A potent and adaptable web server. Anyone wishing to set up a web server or reverse proxy on Ubuntu 20.04 must know how to install and configure Nginx. Here you will understand installing and configuring Nginx on your Ubuntu server. In this article, your web services are safe and operational. With the help of updating or upgrading the Linux kernel which <a href=\"https:\/\/www.dedicatedcore.com\/blog\/update-linux-kernel-ubuntu\/\" target=\"_blank\" rel=\"noopener\">brings stability<\/a> to your system.<\/p>\n<p>A free, open-source Linux program for web servers is called Nginx. By sending web traffic to particular servers, it functions as a reverse proxy server. In addition to being used for load balancing and security, Nginx may run on its own as a web server.<\/p>\n<p><strong>Requirements<\/strong><\/p>\n<ul>\n<li>A machine running Linux Ubuntu 20.04<\/li>\n<li>An account that has root or sudo privileges<\/li>\n<li>The ability to open a command line or terminal window (click Activities &gt; Search &gt; type Terminal)<\/li>\n<\/ul>\n<h2>Install Nginx on Ubuntu 20.04 | 22.04<\/h2>\n<h3>Step 1: Software Repositories Updated<\/h3>\n<p>Refreshing the repository lists is crucial before adding new software. By doing this, you may ensure that the most recent patches and updates are applied.<\/p>\n<p>Enter the Following into an Open Terminal Window:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo apt-get update<\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1173\" src=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/update-software-repositories.png\" alt=\"sudo apt get update software repositories\" width=\"800\" height=\"269\" srcset=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/update-software-repositories.png 800w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/update-software-repositories-300x101.png 300w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/update-software-repositories-150x50.png 150w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/update-software-repositories-768x258.png 768w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/update-software-repositories-100x34.png 100w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/update-software-repositories-700x235.png 700w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/strong><\/p>\n<p>Let the process come to an end.<\/p>\n<h3>Step 2: Utilizing Ubuntu Repositories, Install Nginx<\/h3>\n<p>The default repositories for Ubuntu 20.04 contain Nginx. Enter the following command to install it:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo apt-get install nginx<\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1174\" src=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-get-install-nginx.png\" alt=\"install nginx from ubuntu\" width=\"800\" height=\"504\" srcset=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-get-install-nginx.png 800w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-get-install-nginx-300x189.png 300w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-get-install-nginx-150x95.png 150w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-get-install-nginx-768x484.png 768w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-get-install-nginx-100x63.png 100w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-get-install-nginx-700x441.png 700w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/strong><\/p>\n<h3>Step 3: Check about the Installation<\/h3>\n<p>Verify the program version to make sure Nginx is installed correctly. Add these to the entry:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">nginx -v<\/pre>\n<p>The Nginx software version ought to be visible on the system.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1175\" src=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/nginx-v-verify-installation.png\" alt=\"system display software version of nginx\" width=\"800\" height=\"151\" srcset=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/nginx-v-verify-installation.png 800w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/nginx-v-verify-installation-300x57.png 300w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/nginx-v-verify-installation-150x28.png 150w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/nginx-v-verify-installation-768x145.png 768w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/nginx-v-verify-installation-100x19.png 100w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/nginx-v-verify-installation-700x132.png 700w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/strong><\/p>\n<h3>Step 4: Nginx Service Control<\/h3>\n<p>Nginx&#8217;s behavior is modifiable. Use this to enable or disable Nginx at boot, as well as to start or stop it.<\/p>\n<p>To begin with, see how the Nginx service is doing:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo systemctl status nginx<\/pre>\n<p>If Nginx is shown as active (running), it has already been launched. To close the status display, press CTRL+z.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1176\" src=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-system-status-nginx.png\" alt=\"display status of nginx\" width=\"800\" height=\"369\" srcset=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-system-status-nginx.png 800w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-system-status-nginx-300x138.png 300w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-system-status-nginx-150x69.png 150w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-system-status-nginx-768x354.png 768w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-system-status-nginx-100x46.png 100w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-system-status-nginx-700x323.png 700w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/strong><\/p>\n<p>To start the Nginx service if it&#8217;s not already operating, use the following command:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo systemctl start nginx<\/pre>\n<p>Enter this to configure Nginx to load at system startup:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo systemctl enable nginx<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1180\" src=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-system-enable-nginx-1.png\" alt=\"sudo-system-enable-nginx\" width=\"800\" height=\"190\" srcset=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-system-enable-nginx-1.png 800w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-system-enable-nginx-1-300x71.png 300w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-system-enable-nginx-1-150x36.png 150w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-system-enable-nginx-1-768x182.png 768w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-system-enable-nginx-1-100x24.png 100w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-system-enable-nginx-1-700x166.png 700w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>Enter the following to terminate the Nginx service:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo systemctl stop nginx<\/pre>\n<p>To Stop Nginx from Loading Upon System Startup:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo systemctl disable nginx<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1181\" src=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-system-disable-nginx.png\" alt=\"when system boots prevent nginx from loading\" width=\"800\" height=\"210\" srcset=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-system-disable-nginx.png 800w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-system-disable-nginx-300x79.png 300w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-system-disable-nginx-150x39.png 150w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-system-disable-nginx-768x202.png 768w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-system-disable-nginx-100x26.png 100w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-system-disable-nginx-700x184.png 700w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>The Nginx service can be reloaded to implement configuration changes.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo systemctl reload nginx<\/pre>\n<p>For a Forceful Nginx Restart:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo systemctl restart nginx<\/pre>\n<h3>Step 5: Permit Traffic from Nginx<\/h3>\n<p>Nginx requires access via the firewall of the system. To achieve this, a set of profiles for the Ubuntu default ufw (Uncomplicated Firewall) are installed by Nginx.<\/p>\n<p>To begin, list the available Nginx profiles here:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo ufw app list<\/pre>\n<p>Displays as Below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1183\" src=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-ufw-app-list-1.png\" alt=\"system display app list\" width=\"800\" height=\"209\" srcset=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-ufw-app-list-1.png 800w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-ufw-app-list-1-300x78.png 300w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-ufw-app-list-1-150x39.png 150w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-ufw-app-list-1-768x201.png 768w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-ufw-app-list-1-100x26.png 100w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-ufw-app-list-1-700x183.png 700w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>Enter the following to allow Nginx to pass through the Ubuntu firewall by default:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo ufw allow 'nginx http'<\/pre>\n<p>Rules should be updated on the system.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1184\" src=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-ufw-allow-nginx.png\" alt=\"system displays rules updated\" width=\"800\" height=\"169\" srcset=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-ufw-allow-nginx.png 800w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-ufw-allow-nginx-300x63.png 300w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-ufw-allow-nginx-150x32.png 150w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-ufw-allow-nginx-768x162.png 768w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-ufw-allow-nginx-100x21.png 100w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-ufw-allow-nginx-700x148.png 700w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/strong><\/p>\n<p>Enter the following to update the firewall settings:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo ufw reload<\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1185\" src=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-ufw-reload.png\" alt=\"displays refreshed firewall settings\" width=\"800\" height=\"149\" srcset=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-ufw-reload.png 800w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-ufw-reload-300x56.png 300w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-ufw-reload-150x28.png 150w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-ufw-reload-768x143.png 768w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-ufw-reload-100x19.png 100w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-ufw-reload-700x130.png 700w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/strong><\/p>\n<p>Enter this for encrypted (HTTPS) traffic:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo ufw allow 'nginx https'<\/pre>\n<p>To enable both, type in:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo ufw allow 'nginx full'<\/pre>\n<h3>Step 6: Run Nginx Tests<\/h3>\n<p>As in Step 4, confirm that the Nginx service is up and operating. Launch a browser, then go to the following website:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">http:\/\/127.0.0.1<\/pre>\n<p>The Nginx welcome page should be displayed by the system.<\/p>\n<p>Curl can be used to load the Nginx Welcome page in the terminal if the system lacks a graphical user interface:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo apt-get install curl\r\ncurl \u2013i 127.0.0.1<\/pre>\n<p>The Nginx Welcome page&#8217;s HTML code ought to be shown by the system.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1186\" src=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-get-install-curl.png\" alt=\"system display nginx welcome page\" width=\"800\" height=\"573\" srcset=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-get-install-curl.png 800w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-get-install-curl-300x215.png 300w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-get-install-curl-150x107.png 150w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-get-install-curl-768x550.png 768w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-get-install-curl-100x72.png 100w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-get-install-curl-628x450.png 628w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<h3>Step 7: Server Block Configuration (Optional)<\/h3>\n<p>A server block in Nginx is a configuration that functions independently of other servers. Nginx is preconfigured with one server block.<\/p>\n<p>You can find it at \/var\/www\/html. It can, however, be set up with several server blocks for various websites.<\/p>\n<h4>1. Establish the Test Domain&#8217;s Directory<\/h4>\n<p>Enter the following to create a new directory in a terminal window:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo mkdir -p \/var\/www\/test_domain.com\/html<\/pre>\n<h4>2. Set Up Permissions and Ownership<\/h4>\n<p>To set up ownership and permission rules, use chmod:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo chown \u2013R $USER:$USER \/var\/www\/test_domain.com\r\nsudo chmod \u2013R 755 \/var\/www\/test_domain.com<\/pre>\n<h4>3. Make Sure the Server Block&#8217;s index.html File Exists.<\/h4>\n<p>Open index.html in your preferred text editor (Nano will be used), and modify it there:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo nano \/var\/www\/test_domain.com\/html\/index.html<\/pre>\n<p>Enter the HTML code below in the text editor:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;title&gt;Welcome to test_domain.com!&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;h1&gt;This message confirms that your Nginx server block is working. Great work!&lt;\/h1&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>To save the changes, use CTRL+o. To stop, press CTRL+x.<\/p>\n<h4>4. Produce the Block Configuration for the Nginx Server.<\/h4>\n<p>To edit, open the configuration file:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo nano \/etc\/nginx\/sites-available\/test_domain.com<\/pre>\n<p>Put in the subsequent code:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">server {\r\nlisten 80;\r\n\r\nroot \/var\/www\/test_domain.com\/html;\r\nindex index.html index.htm index.nginx.debian.html;\r\n\r\nserver_name test_domain.com www.test_domain.com;\r\nlocation \/ {\r\ntry_files $uri $uri\/ =404;\r\n}\r\n}<\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1187\" src=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/nginx-server-block-configuration.png\" alt=\"open configuration file\" width=\"800\" height=\"407\" srcset=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/nginx-server-block-configuration.png 800w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/nginx-server-block-configuration-300x153.png 300w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/nginx-server-block-configuration-150x76.png 150w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/nginx-server-block-configuration-768x391.png 768w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/nginx-server-block-configuration-100x51.png 100w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/nginx-server-block-configuration-700x356.png 700w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/strong><\/p>\n<h4>5. Make a Symbolic Connection that Nginx will Read Upon Startup.<\/h4>\n<p>Enter the following to establish a symbolic link between the startup directory and the server block:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo ln \u2013s \/etc\/nginx\/sites-available\/test_domain.com \/etc\/nginx\/sites-enabled<\/pre>\n<h4>6. Turn the Nginx Service Back On.<\/h4>\n<p>Use these instructions to restart Nginx:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo systemctl restart nginx<\/pre>\n<h4>7. Examine the Configuration.<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo nginx \u2013t<\/pre>\n<p>The configuration file test should be successful, and the system should indicate that the configuration file syntax is correct.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1188\" src=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-nginx-t.png\" alt=\"test the configuration\" width=\"800\" height=\"170\" srcset=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-nginx-t.png 800w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-nginx-t-300x64.png 300w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-nginx-t-150x32.png 150w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-nginx-t-768x163.png 768w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-nginx-t-100x21.png 100w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/sudo-nginx-t-700x149.png 700w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/strong><\/p>\n<h4>8. Make Optional Changes to the Host File.<\/h4>\n<p>The file \/etc\/hosts need to be changed to show test_domain.com If you\u2019re utilizing a test domain name that isn\u2019t registered or public<\/p>\n<p>Use this command to see the IP address of the system:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">hostname \u2013i<\/pre>\n<p>Note the IP address that appears.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1189\" src=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/hostname-i-command.png\" alt=\"ip address displayed\" width=\"800\" height=\"151\" srcset=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/hostname-i-command.png 800w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/hostname-i-command-300x57.png 300w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/hostname-i-command-150x28.png 150w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/hostname-i-command-768x145.png 768w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/hostname-i-command-100x19.png 100w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/hostname-i-command-700x132.png 700w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/strong><\/p>\n<p>Next, open \/etc\/hosts for editing:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sudo nano \/etc\/hosts<\/pre>\n<p>Add the following line to the blank space directly below the localhost information:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">127.0.1.1 test_domain.com www.test_domain.com<\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1190\" src=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/change-to-host-file.png\" alt=\"install and configure nginx on ubuntu\" width=\"800\" height=\"372\" srcset=\"https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/change-to-host-file.png 800w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/change-to-host-file-300x140.png 300w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/change-to-host-file-150x70.png 150w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/change-to-host-file-768x357.png 768w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/change-to-host-file-100x47.png 100w, https:\/\/www.dedicatedcore.com\/blog\/wp-content\/uploads\/change-to-host-file-700x326.png 700w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/strong><\/p>\n<p>Instead of 127.0.0.1, enter the IP address that is shown above. To save the changes, use CTRL+o. To exit, press CTRL+x.<\/p>\n<h4>9. Look up test_domain.com Using a Browser.<\/h4>\n<p>Launch a web browser and enter test_domain.com or the domain name you specified in Nginx.<\/p>\n<h4>Final Thoughts on How to Install and Configure Nginx on Ubuntu<\/h4>\n<p>On your Ubuntu 20.04 server, you&#8217;ve made significant progress toward hosting websites. Controlling web applications, and maximizing online traffic now that Nginx has been installed and configured. Nginx is a great option for a range of web-serving activities because of its speed, scalability, and feature-rich set.<\/p>\n<p>You&#8217;ll be well-prepared to provide your users with dependable and quick online services. As you continue to experiment with and optimize your Nginx configuration. At this point, your Ubuntu 20.04 installation of Nginx ought to be operational. You should now have an overview of configuring a Nginx server block as a bonus.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One common option for hosting websites and controlling online traffic is Nginx. A potent and adaptable web server. Anyone wishing to set up a web&#8230;<\/p>\n","protected":false},"author":1,"featured_media":1242,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/posts\/1169"}],"collection":[{"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/comments?post=1169"}],"version-history":[{"count":9,"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/posts\/1169\/revisions"}],"predecessor-version":[{"id":2216,"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/posts\/1169\/revisions\/2216"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/media\/1242"}],"wp:attachment":[{"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/media?parent=1169"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/categories?post=1169"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dedicatedcore.com\/blog\/wp-json\/wp\/v2\/tags?post=1169"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}