{"id":174,"date":"2026-10-21T21:42:28","date_gmt":"2026-10-21T19:42:28","guid":{"rendered":"https:\/\/nodeguard.io\/blog\/?p=174"},"modified":"2026-10-21T21:42:30","modified_gmt":"2026-10-21T19:42:30","slug":"how-to-install-nginx-on-ubuntu","status":"publish","type":"post","link":"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/","title":{"rendered":"How to Install Nginx on Ubuntu in 15 Minutes: Effortless &#038; Secure"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">If you have a fresh Ubuntu server and want to put a website on it, learning how to install Nginx on Ubuntu is the first real job on your list. Nginx (pronounced &#8220;engine-x&#8221;) is fast, light on memory and trusted by many of the busiest sites on the internet. The good news is that the whole setup takes about 15 minutes, even if you have never touched a web server before.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this guide you will install Nginx on Ubuntu, open the right firewall ports, confirm the service is running, learn where every Nginx configuration file lives, create Nginx server blocks for your own domain, and finish with a free SSL certificate. Every step works on Ubuntu 24.04 LTS and Ubuntu 26.04 LTS, and the same commands apply to Ubuntu 22.04.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By the end you will have a working Nginx web server that is ready for a static site, a WordPress blog or an app running behind a reverse proxy.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_86 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">In This Guide<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#Why_Choose_the_Nginx_Web_Server\" >Why Choose the Nginx Web Server?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#What_You_Need_Before_You_Start\" >What You Need Before You Start<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#How_to_Install_Nginx_on_Ubuntu_The_8-Step_Overview\" >How to Install Nginx on Ubuntu: The 8-Step Overview<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#Step_1_Update_Your_Ubuntu_Packages\" >Step 1: Update Your Ubuntu Packages<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#Step_2_Install_Nginx_on_Ubuntu\" >Step 2: Install Nginx on Ubuntu<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#Optional_Install_the_Latest_Nginx_from_the_Official_Repository\" >Optional: Install the Latest Nginx from the Official Repository<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#Step_3_Allow_Nginx_Through_the_UFW_Firewall\" >Step 3: Allow Nginx Through the UFW Firewall<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#Step_4_Check_That_the_Nginx_Web_Server_Is_Running\" >Step 4: Check That the Nginx Web Server Is Running<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#Everyday_Nginx_Service_Commands\" >Everyday Nginx Service Commands<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#Step_5_Understand_the_Nginx_Configuration_Files\" >Step 5: Understand the Nginx Configuration Files<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#Step_6_Create_Nginx_Server_Blocks_for_Your_Domain\" >Step 6: Create Nginx Server Blocks for Your Domain<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#Create_the_Web_Root\" >Create the Web Root<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#Write_the_Server_Block\" >Write the Server Block<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#Enable_the_Site\" >Enable the Site<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#Step_7_Test_Your_Nginx_Configuration_and_Reload\" >Step 7: Test Your Nginx Configuration and Reload<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#Step_8_Secure_Nginx_on_Ubuntu_with_a_Free_SSL_Certificate\" >Step 8: Secure Nginx on Ubuntu with a Free SSL Certificate<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#Quick_Hardening_and_Performance_Tweaks\" >Quick Hardening and Performance Tweaks<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#Troubleshooting_Common_Nginx_on_Ubuntu_Errors\" >Troubleshooting Common Nginx on Ubuntu Errors<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#Frequently_Asked_Questions\" >Frequently Asked Questions<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#Is_Nginx_free_to_use\" >Is Nginx free to use?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#Which_is_better_on_Ubuntu_Nginx_or_Apache\" >Which is better on Ubuntu, Nginx or Apache?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#Where_is_the_main_Nginx_configuration_file_on_Ubuntu\" >Where is the main Nginx configuration file on Ubuntu?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-23\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#How_many_Nginx_server_blocks_can_one_server_host\" >How many Nginx server blocks can one server host?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-24\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#Does_this_guide_work_on_Ubuntu_2404_and_2604\" >Does this guide work on Ubuntu 24.04 and 26.04?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-25\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#How_do_I_uninstall_Nginx_completely\" >How do I uninstall Nginx completely?<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-26\" href=\"https:\/\/nodeguard.io\/blog\/how-to-install-nginx-on-ubuntu\/#Final_Thoughts_Your_Nginx_Web_Server_Is_Live\" >Final Thoughts: Your Nginx Web Server Is Live<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Why_Choose_the_Nginx_Web_Server\"><\/span>Why Choose the Nginx Web Server?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before we start typing commands, it helps to know why so many developers pick the Nginx web server over the alternatives.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>It handles traffic efficiently.<\/strong> Nginx uses an event-driven design. Instead of starting a new process for every visitor, a small number of worker processes handle thousands of connections at once. On a small VPS with 1 or 2 GB of RAM, that difference is easy to feel.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>It does more than serve pages.<\/strong> The same Nginx web server can act as a reverse proxy for Node.js, Python or PHP apps, a load balancer that spreads traffic across several backends, and an SSL terminator that handles HTTPS for everything behind it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The configuration is readable.<\/strong> An Nginx configuration file is plain text built from short, nested blocks. Once you understand one server block, you understand them all.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>It is free and open source.<\/strong> The open source version has no licence costs and is in Ubuntu&#8217;s official package repositories, so installing and updating it is a one-line job.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Apache is still a fine choice, especially if you depend on <code>.htaccess<\/code> files. But for most new projects on a VPS, Nginx on Ubuntu is the faster and leaner starting point.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_You_Need_Before_You_Start\"><\/span>What You Need Before You Start<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To follow this guide on how to install Nginx on Ubuntu, you only need a few things:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>An Ubuntu server.<\/strong> Ubuntu 24.04 or 26.04 LTS is ideal. A small <a href=\"https:\/\/nodeguard.io\/cloud-vps\">Cloud VPS<\/a> with 1 vCPU and 1 GB of RAM is more than enough to learn on.<\/li>\n\n\n\n<li><strong>A non-root user with sudo rights.<\/strong> If your server is brand new, follow our guide on how to <a href=\"https:\/\/nodeguard.io\/blog\/how-to-set-up-an-ubuntu-vps\">set up an Ubuntu VPS<\/a> first. It covers users, updates and basic security.<\/li>\n\n\n\n<li><strong>SSH access.<\/strong> You will run every command over SSH. If you are not sure how, see our guide on how to <a href=\"https:\/\/nodeguard.io\/blog\/how-to-connect-to-a-linux-vps-using-ssh\">connect to a Linux VPS using SSH<\/a>.<\/li>\n\n\n\n<li><strong>A domain name (for steps 6 to 8).<\/strong> Point an <code>A<\/code> record for <code>example.com<\/code> and <code>www.example.com<\/code> at your server&#8217;s public IP address. DNS changes can take a while, so do this first and let it settle while you work.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Throughout this guide, replace <code>example.com<\/code> with your own domain.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Install_Nginx_on_Ubuntu_The_8-Step_Overview\"><\/span>How to Install Nginx on Ubuntu: The 8-Step Overview<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Here is the full roadmap. Steps 1 to 4 get Nginx installed and reachable. Steps 5 to 8 turn it into a proper host for your own website.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/nodeguard.io\/blog\/wp-content\/uploads\/2026\/10\/how-to-install-nginx-on-ubuntu-8-steps-1024x576.webp\" alt=\"How to install Nginx on Ubuntu in 8 steps, from apt update to a free SSL certificate with Certbot\" class=\"wp-image-176\" srcset=\"https:\/\/nodeguard.io\/blog\/wp-content\/uploads\/2026\/10\/how-to-install-nginx-on-ubuntu-8-steps-1024x576.webp 1024w, https:\/\/nodeguard.io\/blog\/wp-content\/uploads\/2026\/10\/how-to-install-nginx-on-ubuntu-8-steps-300x169.webp 300w, https:\/\/nodeguard.io\/blog\/wp-content\/uploads\/2026\/10\/how-to-install-nginx-on-ubuntu-8-steps-768x432.webp 768w, https:\/\/nodeguard.io\/blog\/wp-content\/uploads\/2026\/10\/how-to-install-nginx-on-ubuntu-8-steps-900x506.webp 900w, https:\/\/nodeguard.io\/blog\/wp-content\/uploads\/2026\/10\/how-to-install-nginx-on-ubuntu-8-steps.webp 1200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">The 8 steps to install Nginx on Ubuntu and take your first site live.<\/figcaption><\/figure>\n<\/blockquote>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Update your Ubuntu packages<\/li>\n\n\n\n<li>Install Nginx on Ubuntu<\/li>\n\n\n\n<li>Allow Nginx through the UFW firewall<\/li>\n\n\n\n<li>Check that the Nginx web server is running<\/li>\n\n\n\n<li>Understand the Nginx configuration files<\/li>\n\n\n\n<li>Create Nginx server blocks for your domain<\/li>\n\n\n\n<li>Test the configuration and reload<\/li>\n\n\n\n<li>Secure your site with a free SSL certificate<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s go.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_1_Update_Your_Ubuntu_Packages\"><\/span>Step 1: Update Your Ubuntu Packages<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Always refresh the package index before installing anything. This makes sure apt downloads the latest version available for your release, along with any security fixes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt upgrade -y\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The first command downloads the current list of packages. The second installs any pending updates. If the upgrade includes a new kernel, reboot with <code>sudo reboot<\/code> and reconnect before moving on.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_2_Install_Nginx_on_Ubuntu\"><\/span>Step 2: Install Nginx on Ubuntu<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Nginx is in Ubuntu&#8217;s default repositories, so one command is all it takes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install nginx -y\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Apt installs the Nginx package, creates the <code>www-data<\/code> user it runs as, registers a systemd service, and starts it straight away. Check the installed version with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nginx -v\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You should see something like <code>nginx version: nginx\/1.x.x<\/code>. The exact number depends on your Ubuntu release. Ubuntu keeps this version stable for the life of the release and backports security fixes into it, which is exactly what you want on a production server.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Optional_Install_the_Latest_Nginx_from_the_Official_Repository\"><\/span>Optional: Install the Latest Nginx from the Official Repository<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Ubuntu&#8217;s package is the safest choice for most people. If you need a newer feature, the Nginx team publishes its own repository. Add it like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring -y\ncurl https:\/\/nginx.org\/keys\/nginx_signing.key | gpg --dearmor \\\n  | sudo tee \/usr\/share\/keyrings\/nginx-archive-keyring.gpg &gt;\/dev\/null\necho \"deb &#91;signed-by=\/usr\/share\/keyrings\/nginx-archive-keyring.gpg] \\\nhttp:\/\/nginx.org\/packages\/ubuntu $(lsb_release -cs) nginx\" \\\n  | sudo tee \/etc\/apt\/sources.list.d\/nginx.list\nprintf \"Package: *\\nPin: origin nginx.org\\nPin: release o=nginx\\nPin-Priority: 900\\n\" \\\n  | sudo tee \/etc\/apt\/preferences.d\/99nginx\nsudo apt update\nsudo apt install nginx -y\nsudo systemctl enable --now nginx\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Before you choose this route, check the <a href=\"https:\/\/nginx.org\/en\/linux_packages.html\" target=\"_blank\" rel=\"noopener\">official Nginx Linux packages page<\/a> to confirm your Ubuntu release is supported. Two differences matter later in this guide. First, the official package keeps site files in <code>\/etc\/nginx\/conf.d\/<\/code> instead of <code>sites-available<\/code> and <code>sites-enabled<\/code>. Second, it does not ship the UFW application profiles, so you open ports by number in the next step.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_3_Allow_Nginx_Through_the_UFW_Firewall\"><\/span>Step 3: Allow Nginx Through the UFW Firewall<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If UFW is active on your server (and it should be), it will block web traffic until you allow it. Ubuntu&#8217;s Nginx package registers three firewall profiles. List them:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ufw app list\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You will see output like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Available applications:\n  Nginx Full\n  Nginx HTTP\n  Nginx HTTPS\n  OpenSSH\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Nginx HTTP<\/strong> opens port 80 only.<\/li>\n\n\n\n<li><strong>Nginx HTTPS<\/strong> opens port 443 only.<\/li>\n\n\n\n<li><strong>Nginx Full<\/strong> opens both ports 80 and 443.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Because you will add SSL in step 8, allow the full profile now. Always make sure SSH stays open before you enable the firewall, or you will lock yourself out:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ufw allow OpenSSH\nsudo ufw allow 'Nginx Full'\nsudo ufw enable\nsudo ufw status\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you installed Nginx from the official repository, use <code>sudo ufw allow 80,443\/tcp<\/code> instead of the profile name. For a deeper walkthrough of rules, ports and rate limiting, read our guide on how to <a href=\"https:\/\/nodeguard.io\/blog\/how-to-configure-ufw-firewall-on-ubuntu\">configure the UFW firewall on Ubuntu<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_4_Check_That_the_Nginx_Web_Server_Is_Running\"><\/span>Step 4: Check That the Nginx Web Server Is Running<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Ubuntu starts Nginx automatically after installation. Confirm it with systemd:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl status nginx\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Look for <code>Active: active (running)<\/code> in green. Press <code>q<\/code> to exit the status view.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next, test the server from the command line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -I http:\/\/localhost\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A healthy Nginx web server replies with <code>HTTP\/1.1 200 OK<\/code> and a <code>Server: nginx<\/code> header. Finally, find your server&#8217;s public IP address and open it in a browser:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>hostname -I\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Visit <code>http:\/\/YOUR_SERVER_IP<\/code> and you should see the default <strong>&#8220;Welcome to nginx!&#8221;<\/strong> page. If you do, you have successfully installed Nginx on Ubuntu. If the page does not load, jump to the troubleshooting section further down.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Everyday_Nginx_Service_Commands\"><\/span>Everyday Nginx Service Commands<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You will use these commands all the time, so keep them handy:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl stop nginx      # stop the server\nsudo systemctl start nginx     # start it again\nsudo systemctl restart nginx   # full stop and start\nsudo systemctl reload nginx    # apply config changes without dropping connections\nsudo systemctl disable nginx   # do not start at boot\nsudo systemctl enable nginx    # start at boot (the default)\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Prefer <code>reload<\/code> over <code>restart<\/code> whenever you change a configuration file. A reload applies the new settings while existing visitors keep their connections.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_5_Understand_the_Nginx_Configuration_Files\"><\/span>Step 5: Understand the Nginx Configuration Files<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before you build your own site, take two minutes to learn how the Nginx configuration is organised on Ubuntu. Everything lives under <code>\/etc\/nginx\/<\/code>:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Path<\/th><th>What it does<\/th><\/tr><\/thead><tbody><tr><td><code>\/etc\/nginx\/nginx.conf<\/code><\/td><td>The main configuration file. Global settings such as worker processes, logging and gzip.<\/td><\/tr><tr><td><code>\/etc\/nginx\/sites-available\/<\/code><\/td><td>One file per website. Files here are stored but not active.<\/td><\/tr><tr><td><code>\/etc\/nginx\/sites-enabled\/<\/code><\/td><td>Symbolic links to the sites you want live. Nginx only loads these.<\/td><\/tr><tr><td><code>\/etc\/nginx\/conf.d\/<\/code><\/td><td>Extra configuration snippets loaded automatically.<\/td><\/tr><tr><td><code>\/etc\/nginx\/snippets\/<\/code><\/td><td>Reusable blocks you can include in several sites, such as SSL settings.<\/td><\/tr><tr><td><code>\/var\/www\/html\/<\/code><\/td><td>The default web root that holds the welcome page.<\/td><\/tr><tr><td><code>\/var\/log\/nginx\/<\/code><\/td><td><code>access.log<\/code> and <code>error.log<\/code>, your first stop when something breaks.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The key idea is the split between <strong>sites-available<\/strong> and <strong>sites-enabled<\/strong>. You write a site&#8217;s Nginx configuration in <code>sites-available<\/code>, then switch it on by creating a link in <code>sites-enabled<\/code>. Removing the link switches the site off without deleting your work. This keeps the Nginx configuration on Ubuntu tidy, even when you host a dozen domains on one server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Nginx configuration uses <strong>directives<\/strong> (single settings ending in a semicolon) and <strong>blocks<\/strong> (groups of directives inside curly braces). The <code>http<\/code> block in <code>nginx.conf<\/code> contains <code>server<\/code> blocks, and each <code>server<\/code> block can contain <code>location<\/code> blocks. The full reference lives in the <a href=\"https:\/\/nginx.org\/en\/docs\/\" target=\"_blank\" rel=\"noopener\">official Nginx documentation<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_6_Create_Nginx_Server_Blocks_for_Your_Domain\"><\/span>Step 6: Create Nginx Server Blocks for Your Domain<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Nginx server blocks are the equivalent of Apache virtual hosts. Each block tells Nginx which domain it answers for and where that site&#8217;s files live. With Nginx server blocks, one server can host many websites side by side.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/nodeguard.io\/blog\/wp-content\/uploads\/2026\/10\/nginx-server-blocks-anatomy-1024x576.webp\" alt=\"Anatomy of Nginx server blocks \u2013 the listen, server_name, root, index and location directives in an Nginx configuration file\" class=\"wp-image-177\" srcset=\"https:\/\/nodeguard.io\/blog\/wp-content\/uploads\/2026\/10\/nginx-server-blocks-anatomy-1024x576.webp 1024w, https:\/\/nodeguard.io\/blog\/wp-content\/uploads\/2026\/10\/nginx-server-blocks-anatomy-300x169.webp 300w, https:\/\/nodeguard.io\/blog\/wp-content\/uploads\/2026\/10\/nginx-server-blocks-anatomy-768x432.webp 768w, https:\/\/nodeguard.io\/blog\/wp-content\/uploads\/2026\/10\/nginx-server-blocks-anatomy-900x506.webp 900w, https:\/\/nodeguard.io\/blog\/wp-content\/uploads\/2026\/10\/nginx-server-blocks-anatomy.webp 1200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Every directive in a basic server block, and what it controls.<\/figcaption><\/figure>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Create_the_Web_Root\"><\/span>Create the Web Root<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Make a folder for your site and give your user ownership so you can edit files without sudo:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkdir -p \/var\/www\/example.com\/html\nsudo chown -R $USER:$USER \/var\/www\/example.com\/html\nsudo chmod -R 755 \/var\/www\/example.com\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add a simple test page:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nano \/var\/www\/example.com\/html\/index.html\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n  &lt;head&gt;&lt;title&gt;example.com is live&lt;\/title&gt;&lt;\/head&gt;\n  &lt;body&gt;&lt;h1&gt;Success! Nginx on Ubuntu is serving example.com&lt;\/h1&gt;&lt;\/body&gt;\n&lt;\/html&gt;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Save with <code>Ctrl+O<\/code>, press <code>Enter<\/code>, then exit with <code>Ctrl+X<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Write_the_Server_Block\"><\/span>Write the Server Block<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create a new file in <code>sites-available<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/nginx\/sites-available\/example.com\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Paste this configuration:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>server {\n    listen 80;\n    listen &#91;::]:80;\n\n    server_name example.com www.example.com;\n\n    root \/var\/www\/example.com\/html;\n    index index.html index.htm;\n\n    access_log \/var\/log\/nginx\/example.com.access.log;\n    error_log  \/var\/log\/nginx\/example.com.error.log;\n\n    location \/ {\n        try_files $uri $uri\/ =404;\n    }\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here is what each line does:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>listen 80;<\/code> and <code>listen [::]:80;<\/code> accept HTTP traffic on IPv4 and IPv6.<\/li>\n\n\n\n<li><code>server_name<\/code> lists the domains this block answers for. Nginx matches it against the <code>Host<\/code> header the browser sends.<\/li>\n\n\n\n<li><code>root<\/code> points to the folder that holds the site&#8217;s files.<\/li>\n\n\n\n<li><code>index<\/code> sets which file loads when someone visits a folder.<\/li>\n\n\n\n<li><code>access_log<\/code> and <code>error_log<\/code> give the site its own log files, which makes debugging much easier on a busy server.<\/li>\n\n\n\n<li><code>location \/<\/code> with <code>try_files<\/code> serves the requested file or folder, and returns a clean 404 if neither exists.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Enable_the_Site\"><\/span>Enable the Site<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Link the file into <code>sites-enabled<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ln -s \/etc\/nginx\/sites-available\/example.com \/etc\/nginx\/sites-enabled\/\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If this server will only host your own sites, you can switch off the default welcome page. This only removes the link; the original file stays in <code>sites-available<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo rm \/etc\/nginx\/sites-enabled\/default\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To add a second website later, repeat this step with a new web root and a new file. That is the real power of Nginx server blocks: every site is isolated in its own file, with its own logs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_7_Test_Your_Nginx_Configuration_and_Reload\"><\/span>Step 7: Test Your Nginx Configuration and Reload<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Never reload Nginx without testing first. A single missing semicolon can stop every site on the server from loading. Nginx includes a built-in syntax checker:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nginx -t\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A healthy result looks like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nginx: the configuration file \/etc\/nginx\/nginx.conf syntax is ok\nnginx: configuration file \/etc\/nginx\/nginx.conf test is successful\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you see <code>could not build server_names_hash<\/code>, open <code>\/etc\/nginx\/nginx.conf<\/code>, find the line <code># server_names_hash_bucket_size 64;<\/code>, remove the <code>#<\/code>, save, and test again. This happens when you host long or many domain names.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once the test passes, apply the change:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl reload nginx\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now visit <code>http:\/\/example.com<\/code>. You should see your <strong>Success!<\/strong> page instead of the default welcome screen. Make <code>nginx -t<\/code> followed by <code>reload<\/code> a habit after every change to your Nginx configuration. It takes two seconds and protects every site on the box.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_8_Secure_Nginx_on_Ubuntu_with_a_Free_SSL_Certificate\"><\/span>Step 8: Secure Nginx on Ubuntu with a Free SSL Certificate<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Modern browsers flag plain HTTP sites as &#8220;Not secure&#8221;, and search engines prefer HTTPS. <a href=\"https:\/\/letsencrypt.org\/\" target=\"_blank\" rel=\"noopener\">Let&#8217;s Encrypt<\/a> issues free, trusted certificates, and the Certbot tool installs them into Nginx for you.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Install Certbot and its Nginx plugin:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install certbot python3-certbot-nginx -y\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Request a certificate for both versions of your domain:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo certbot --nginx -d example.com -d www.example.com\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Certbot asks for an email address for renewal notices and for you to accept the terms. It then proves you control the domain, downloads the certificate and edits your server block to add the SSL settings. When it asks, choose to redirect all HTTP traffic to HTTPS.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Certificates last 90 days, but Certbot renews them automatically with a systemd timer. Confirm renewal works with a dry run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo certbot renew --dry-run\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Visit <code>https:\/\/example.com<\/code> and you should see the padlock in the address bar. Your Nginx on Ubuntu setup is now encrypted end to end. The EFF also maintains a snap-based installer; the <a href=\"https:\/\/certbot.eff.org\/\" target=\"_blank\" rel=\"noopener\">Certbot instructions<\/a> cover that route if you prefer it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Quick_Hardening_and_Performance_Tweaks\"><\/span>Quick Hardening and Performance Tweaks<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Your site is live, but a few small changes make the Nginx web server safer and faster. Open the main file with <code>sudo nano \/etc\/nginx\/nginx.conf<\/code> and look inside the <code>http { }<\/code> block.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Hide the version number.<\/strong> By default, Nginx shows its version in error pages and headers. Attackers use version numbers to look for known bugs. Find <code># server_tokens off;<\/code>, remove the <code>#<\/code> and save.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Turn on compression for more file types.<\/strong> Ubuntu enables <code>gzip on;<\/code> already, but the list of file types is commented out. Uncomment the <code>gzip_types<\/code> line so CSS, JavaScript and JSON are compressed too. Smaller files mean faster pages.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Allow larger uploads if you need them.<\/strong> Nginx rejects request bodies over 1 MB by default, which breaks WordPress media uploads. Add <code>client_max_body_size 64M;<\/code> inside the <code>http<\/code> block or inside a single server block.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Let Nginx size itself.<\/strong> Check that <code>worker_processes auto;<\/code> is set. This starts one worker per CPU core, which is the right default for almost every server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Test and reload after each change:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nginx -t &amp;&amp; sudo systemctl reload nginx\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">These tweaks take five minutes and are worth doing on every new server. If you plan to run PHP or WordPress next, you would add PHP-FPM and a <code>location ~ \\.php$<\/code> block to the same server block. That is a topic for its own guide.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Troubleshooting_Common_Nginx_on_Ubuntu_Errors\"><\/span>Troubleshooting Common Nginx on Ubuntu Errors<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Most problems with Nginx on Ubuntu come down to a handful of causes. Start with the logs. They almost always tell you exactly what went wrong:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tail -n 50 \/var\/log\/nginx\/error.log\nsudo journalctl -u nginx --since \"10 minutes ago\"\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>&#8220;bind() to 0.0.0.0:80 failed (Address already in use)&#8221;.<\/strong> Another program, usually Apache, is already using port 80. Find it with <code>sudo ss -tulpn | grep ':80'<\/code>. If it is Apache and you do not need it, run <code>sudo systemctl disable --now apache2<\/code> and start Nginx again.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The browser times out.<\/strong> The firewall is the usual cause. Run <code>sudo ufw status<\/code> and make sure <code>Nginx Full<\/code> (or ports 80 and 443) is allowed. Some hosting providers also run a network firewall in their control panel, so check that too.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>You still see the &#8220;Welcome to nginx!&#8221; page.<\/strong> Your request is not matching your server block. Check that <code>server_name<\/code> is spelled correctly, that the link exists in <code>sites-enabled<\/code>, and that DNS for your domain points at this server. Run <code>dig +short example.com<\/code> to confirm.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>403 Forbidden.<\/strong> Nginx can reach the folder but cannot read it, or there is no <code>index.html<\/code>. Check the file exists and that folders are readable with <code>ls -la \/var\/www\/example.com\/html<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>502 Bad Gateway.<\/strong> Nginx is working, but the app behind it (PHP-FPM, Node.js or similar) is down or listening on a different socket or port. Check that service, not Nginx.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Your changes do nothing.<\/strong> You probably edited the file but did not reload. Run <code>sudo nginx -t<\/code> and then <code>sudo systemctl reload nginx<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Frequently_Asked_Questions\"><\/span>Frequently Asked Questions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Is_Nginx_free_to_use\"><\/span>Is Nginx free to use?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. The open source Nginx web server is free for personal and commercial use. A paid commercial edition adds extra monitoring and support features, but you do not need it to host websites.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Which_is_better_on_Ubuntu_Nginx_or_Apache\"><\/span>Which is better on Ubuntu, Nginx or Apache?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Both are excellent. Nginx generally uses less memory and handles many simultaneous visitors more efficiently, which suits a VPS. Apache is easier if your software relies on <code>.htaccess<\/code> files. Many servers run Nginx in front as a reverse proxy and Apache or an app server behind it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Where_is_the_main_Nginx_configuration_file_on_Ubuntu\"><\/span>Where is the main Nginx configuration file on Ubuntu?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The main Nginx configuration file is <code>\/etc\/nginx\/nginx.conf<\/code>. Individual websites live in <code>\/etc\/nginx\/sites-available\/<\/code> and are switched on with links in <code>\/etc\/nginx\/sites-enabled\/<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_many_Nginx_server_blocks_can_one_server_host\"><\/span>How many Nginx server blocks can one server host?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">There is no fixed limit. One modest VPS can comfortably run dozens of Nginx server blocks for low-traffic sites. In practice, CPU, RAM and disk space set the limit, not Nginx.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Does_this_guide_work_on_Ubuntu_2404_and_2604\"><\/span>Does this guide work on Ubuntu 24.04 and 26.04?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. This guide on how to install Nginx on Ubuntu works the same on Ubuntu 22.04, 24.04 and 26.04 LTS. Only the Nginx version number in the package differs between releases.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_do_I_uninstall_Nginx_completely\"><\/span>How do I uninstall Nginx completely?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run <code>sudo apt purge nginx nginx-common -y<\/code> followed by <code>sudo apt autoremove -y<\/code>. This removes the packages and their configuration files. Back up <code>\/etc\/nginx\/<\/code> and <code>\/var\/www\/<\/code> first if you want to keep your sites.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Final_Thoughts_Your_Nginx_Web_Server_Is_Live\"><\/span>Final Thoughts: Your Nginx Web Server Is Live<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You now know how to install Nginx on Ubuntu from start to finish. You updated the system, installed the package, opened the firewall, checked the service, learned the Nginx configuration layout, built your own Nginx server blocks, tested and reloaded safely, and added a free SSL certificate. That is a complete, production-ready foundation in about 15 minutes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">From here you can add PHP-FPM for WordPress, put a Node.js or Python app behind a reverse proxy, or host more domains with new server blocks. Each one builds on exactly what you did today.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Need a fast, reliable server to run it on? A NodeGuard <a href=\"https:\/\/nodeguard.io\/cloud-vps\">Cloud VPS<\/a> gives you full root access, NVMe storage and a clean Ubuntu install, so you can have Nginx on Ubuntu running in minutes.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you have a fresh Ubuntu server and want to put a website on it, learning how to install Nginx on Ubuntu\u2026<\/p>\n","protected":false},"author":2,"featured_media":175,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[89,25],"tags":[94,49,90,93,7,92,38,74,91],"class_list":["post-174","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-servers","category-server-management","tag-lets-encrypt","tag-linux","tag-nginx","tag-nginx-server-blocks","tag-ubuntu","tag-ubuntu-24-04","tag-ubuntu-26-04","tag-vps-tutorial","tag-web-server"],"_links":{"self":[{"href":"https:\/\/nodeguard.io\/blog\/wp-json\/wp\/v2\/posts\/174","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nodeguard.io\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nodeguard.io\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nodeguard.io\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nodeguard.io\/blog\/wp-json\/wp\/v2\/comments?post=174"}],"version-history":[{"count":1,"href":"https:\/\/nodeguard.io\/blog\/wp-json\/wp\/v2\/posts\/174\/revisions"}],"predecessor-version":[{"id":178,"href":"https:\/\/nodeguard.io\/blog\/wp-json\/wp\/v2\/posts\/174\/revisions\/178"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nodeguard.io\/blog\/wp-json\/wp\/v2\/media\/175"}],"wp:attachment":[{"href":"https:\/\/nodeguard.io\/blog\/wp-json\/wp\/v2\/media?parent=174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nodeguard.io\/blog\/wp-json\/wp\/v2\/categories?post=174"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nodeguard.io\/blog\/wp-json\/wp\/v2\/tags?post=174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}