{"id":5621,"date":"2023-12-06T12:26:12","date_gmt":"2023-12-06T12:26:12","guid":{"rendered":"https:\/\/natsav.com\/blog\/?p=5621"},"modified":"2024-01-27T11:08:13","modified_gmt":"2024-01-27T11:08:13","slug":"install-nginx-on-ubuntu","status":"publish","type":"post","link":"https:\/\/natsav.com\/blog\/install-nginx-on-ubuntu\/","title":{"rendered":"How to install Ngnix on Ubuntu"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_68_1 counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Table of Contents<\/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-4'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/natsav.com\/blog\/install-nginx-on-ubuntu\/#1_Update_Package_Lists_Before_installing_any_new_software_its_a_good_practice_to_update_the_package_lists_on_your_system\" title=\"1. Update Package Lists: Before installing any new software, it&#8217;s a good practice to update the package lists on your system.\">1. Update Package Lists: Before installing any new software, it&#8217;s a good practice to update the package lists on your system.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/natsav.com\/blog\/install-nginx-on-ubuntu\/#2_Install_Nginx_on_Ubuntu_Use_the_following_command_to_install_Nginx\" title=\"2. Install Nginx on Ubuntu: Use the following command to install Nginx.\">2. Install Nginx on Ubuntu: Use the following command to install Nginx.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/natsav.com\/blog\/install-nginx-on-ubuntu\/#3_Start_Nginx_After_the_installation_is_complete_start_the_Nginx_service\" title=\"3. Start Nginx: After the installation is complete, start the Nginx service.\">3. Start Nginx: After the installation is complete, start the Nginx service.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/natsav.com\/blog\/install-nginx-on-ubuntu\/#4_Enable_Nginx_to_Start_on_Boot_Ensure_that_Nginx_starts_automatically_when_the_system_boots\" title=\"4. Enable Nginx to Start on Boot: Ensure that Nginx starts automatically when the system boots.\">4. Enable Nginx to Start on Boot: Ensure that Nginx starts automatically when the system boots.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/natsav.com\/blog\/install-nginx-on-ubuntu\/#5_Check_Nginx_Status_Confirm_that_Nginx_is_running_without_errors\" title=\"5. Check Nginx Status: Confirm that Nginx is running without errors.\">5. Check Nginx Status: Confirm that Nginx is running without errors.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/natsav.com\/blog\/install-nginx-on-ubuntu\/#6Configure_Firewall_If_you_have_a_firewall_enabled_such_as_UFW\" title=\"6.Configure Firewall: If you have a firewall enabled, such as UFW,\">6.Configure Firewall: If you have a firewall enabled, such as UFW,<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/natsav.com\/blog\/install-nginx-on-ubuntu\/#7Adjust_the_firewall_rules_based_on_your_specific_requirements\" title=\"7.Adjust the firewall rules based on your specific requirements.\">7.Adjust the firewall rules based on your specific requirements.<\/a><\/li><\/ul><\/nav><\/div>\n<h4><span class=\"ez-toc-section\" id=\"1_Update_Package_Lists_Before_installing_any_new_software_its_a_good_practice_to_update_the_package_lists_on_your_system\"><\/span><span style=\"color: #003366;\">1. Update Package Lists: Before installing any new software, it&#8217;s a good practice to update the package lists on your system.<\/span><span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>sudo apt update<\/p>\n<h4><span class=\"ez-toc-section\" id=\"2_Install_Nginx_on_Ubuntu_Use_the_following_command_to_install_Nginx\"><\/span><span style=\"color: #003366;\">2. Install Nginx on Ubuntu: Use the following command to install Nginx.<\/span><span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>sudo apt install nginx<\/p>\n<h4><span class=\"ez-toc-section\" id=\"3_Start_Nginx_After_the_installation_is_complete_start_the_Nginx_service\"><\/span><span style=\"color: #003300;\">3. Start Nginx: After the installation is complete, start the Nginx service.<\/span><span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>sudo systemctl start nginx<\/p>\n<h4><span class=\"ez-toc-section\" id=\"4_Enable_Nginx_to_Start_on_Boot_Ensure_that_Nginx_starts_automatically_when_the_system_boots\"><\/span><span style=\"color: #003366;\">4. Enable Nginx to Start on Boot: Ensure that Nginx starts automatically when the system boots.<\/span><span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>sudo systemctl enable nginx<\/p>\n<h4><span class=\"ez-toc-section\" id=\"5_Check_Nginx_Status_Confirm_that_Nginx_is_running_without_errors\"><\/span><span style=\"color: #003366;\">5. Check Nginx Status: Confirm that Nginx is running without errors.<\/span><span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>sudo systemctl status nginx<\/p>\n<p>This command will display the status and other information about the Nginx service.<\/p>\n<h4><span class=\"ez-toc-section\" id=\"6Configure_Firewall_If_you_have_a_firewall_enabled_such_as_UFW\"><\/span><span style=\"color: #003366;\">6.Configure Firewall: If you have a firewall enabled, such as UFW,<\/span><span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><span style=\"color: #003366;\">you may need to allow traffic on port 80 (HTTP) and\/or port 443 (HTTPS). If UFW is not installed, you can install it and configure it with the following commands:<\/span><\/pre>\n<p>sudo apt install ufw<br \/>\nsudo ufw allow &#8216;Nginx HTTP&#8217;<br \/>\nsudo ufw allow &#8216;Nginx HTTPS&#8217;<br \/>\nsudo ufw enable<\/p>\n<h4><span class=\"ez-toc-section\" id=\"7Adjust_the_firewall_rules_based_on_your_specific_requirements\"><\/span><span style=\"color: #003366;\">7.Adjust the firewall rules based on your specific requirements.<\/span><span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>Access Nginx Default Page: Open a web browser and enter your server&#8217;s IP address or domain name. You should see the default Nginx welcome page, indicating that the <a href=\"https:\/\/natsav.com\/blog\/install-php-7-4-in-ubuntu\/\"><strong>installation<\/strong><\/a> was successful.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Update Package Lists: Before installing any new software, it&#8217;s a good practice to update the package lists on your system. sudo apt update 2. Install Nginx on Ubuntu: Use the following command to install Nginx. sudo apt install nginx 3. Start Nginx: After the installation is complete, start the Nginx service. sudo systemctl start [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5623,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[255],"tags":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/i0.wp.com\/natsav.com\/blog\/wp-content\/uploads\/2023\/12\/ubuntu-nginix.png?fit=572%2C297&ssl=1","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/posts\/5621"}],"collection":[{"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/comments?post=5621"}],"version-history":[{"count":9,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/posts\/5621\/revisions"}],"predecessor-version":[{"id":5839,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/posts\/5621\/revisions\/5839"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/media\/5623"}],"wp:attachment":[{"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/media?parent=5621"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/categories?post=5621"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/natsav.com\/blog\/wp-json\/wp\/v2\/tags?post=5621"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}