<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Oyame Ogbeche</title>
    <description>The latest articles on DEV Community by Oyame Ogbeche (@oyogbeche).</description>
    <link>https://dev.to/oyogbeche</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2446232%2Fa640ea14-b085-4cf0-9088-67fb53458a9a.jpg</url>
      <title>DEV Community: Oyame Ogbeche</title>
      <link>https://dev.to/oyogbeche</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/oyogbeche"/>
    <language>en</language>
    <item>
      <title>Hosting a Web App with Nginx on Ubuntu: A Step-by-Step Guide</title>
      <dc:creator>Oyame Ogbeche</dc:creator>
      <pubDate>Wed, 29 Jan 2025 14:02:18 +0000</pubDate>
      <link>https://dev.to/oyogbeche/hosting-a-web-app-with-nginx-on-ubuntu-a-step-by-step-guide-16n6</link>
      <guid>https://dev.to/oyogbeche/hosting-a-web-app-with-nginx-on-ubuntu-a-step-by-step-guide-16n6</guid>
      <description>&lt;p&gt;Deploying a web app doesn’t have to be complicated. Whether you're launching a personal project, a company landing page, or just testing the waters, Nginx on Ubuntu provides a fast, efficient, and scalable way to serve your web content. In this guide, we'll walk through provisioning an Ubuntu server, installing Nginx, and hosting an HTML page. Let's get started.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Provision an Ubuntu Server&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before hosting your web app, you need a server. If you don’t already have one, you can quickly spin up an Ubuntu Server using any cloud provider like AWS, DigitalOcean, Linode, or even a local Virtual Machine.&lt;/p&gt;

&lt;p&gt;I will be using AWS EC2 in this guide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Navigate to the EC2 dashboard and launch an instance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose an Ubuntu 22.04 LTS Amazon Machine Image (AMI).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select an instance type (t2.micro for testing is fine).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Configure security groups to allow SSH (port 22) and HTTP (port 80) traffic.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Launch the instance and connect to it via SSH:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  ssh ubuntu@your-server-ip &lt;span class="nt"&gt;-i&lt;/span&gt; your-key.pem
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Install Nginx&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once you're logged into your Ubuntu server, the first thing you need to do is install Nginx, which will act as your web server.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Update your package list to ensure you have the latest versions:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;sudo &lt;/span&gt;apt update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt upgrade &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Install nginx:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;nginx &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Start and enable the nginx server to ensure it's running:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl start nginx
  &lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Verify nginx is running:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl status nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see this output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F19wa5qdmuvaqn80w43ck.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F19wa5qdmuvaqn80w43ck.png" alt="Nginx status" width="800" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Build and Host Your HTML Page&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now that Nginx is running, it's time to serve your custom HTML page.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Navigate to the default web root directory:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;cd&lt;/span&gt; /var/www/html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Remove the default &lt;code&gt;index.html&lt;/code&gt; file (optional):
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;sudo rm &lt;/span&gt;index.nginx-debian.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Create a new &lt;code&gt;index.html&lt;/code&gt; file:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;sudo &lt;/span&gt;nana index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Add your custom html content&lt;/li&gt;
&lt;li&gt;Save the file (CTRL + X, then Y, then Enter)
-Restart nginx to apply changes
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  &lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl restart nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;You can view your page with the public IP of your server. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw3nrw04qz8pk6ggjf7u5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw3nrw04qz8pk6ggjf7u5.png" alt="web page" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Congratulations! You’ve successfully set up an Nginx web server on Ubuntu and hosted a simple HTML page. This is just the beginning.&lt;/p&gt;

&lt;p&gt;Need more insights or facing any issues? Drop your questions in the comments! You can also connect on &lt;a href="https://www.linkedin.com/in/oyameogbeche/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; or &lt;a href="https://x.com/oyameogbeche" rel="noopener noreferrer"&gt;X&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Looking to hire Engineers? &lt;br&gt;
&lt;a href="https://hng.tech/hire/devops-engineers" rel="noopener noreferrer"&gt;DevOps Engineers&lt;/a&gt;&lt;br&gt;
&lt;a href="https://hng.tech/hire/cloud-engineers" rel="noopener noreferrer"&gt;Cloud Engineers&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
