DEV Community

ODINKEMELU INNOCENT
ODINKEMELU INNOCENT

Posted on

Deploying My First NGINX Web Server on AWS EC2: A Beginner-Friendly Walkthrough

INTRODUCTION
Cloud computing is about using powerful computers hosted online instead of relying on your personal device. Think of it like renting a house: you can use it when you need it, without worrying about building or maintaining it.

Amazon Web Services (AWS) is one of the most popular platforms for cloud computing. One of its key services is EC2 (Elastic Compute Cloud), which lets you rent virtual computers called instances. These instances allow you to run applications, websites, or other services directly from the cloud.

  1. Launching an EC2 Instance

Here are the steps I followed to launch my virtual server:

1.Logged into the AWS Management Console.

Amazon Webserver online page, red arrow showing AWS loggo, while green arrow showing signing up to console

AWS Console page, logging in with Account ID,IAM Username and Password

AWS Console Home, click search on EC2

2.Navigated to Services > EC2 > Launch Instance.

AWS Console EC2 navigated by Clicking Lunch Instance button

3.Named the instance: my-nginx33.
The EC2 Instance Named,my-nginx33

4.Selected Ubuntu Server 22.04 LTS as the operating system.

Red arrow clicked on the button selecting Ubuntu as OS,Green arrow showing AMI on Ubuntu Server 24.4 LTS, Blue arrow showing the Free tier eligible

.Ubuntu is a version of Linux widely used for cloud servers.
Enter fullscreen mode Exit fullscreen mode

5.Chose instance type: t2.micro (eligible for the AWS Free Tier).

Red arrow showing the selected Instance type which is t2.micro and Blue arrow indicating it is on free tier eligible

6.Created a new key pair called " my-2P-key " and i downloaded the .pem file. Then after downloading the ".pem " file , it will appear/ becomes " my-2P-key.pem "

The red arrow showing the key pair created

This file acts as a secure key for connecting to the server.

7.Configured security group rules to allow:

SSH on port 22 for remote access.

HTTP on port 80 for web access.

Network Settings, Network-vpc indicated by blue arrow,Default Subnet indicated by green arrow and Auto-assign Public IP indicated by red arrow

Firewall(Security group), red arrow indicating default Create Security Group, blue arrow indicating Allow SSH traffic from, green arrow indicating Allow HTPP from the internet

Image Showing the Default Configure Storage

8.Clicked Launch Instance.

The Add new Volume indicated by red arrow was on default, Then Advanced details was also on default indicated by blue arrow

Click the Lunch Instance button to lunch, indicated by the red arrow
Analogy: The EC2 instance is like renting a small apartment in the cloud, and the security group is like deciding which doors and windows are unlocked for visitors.

Launching the Instance and the blue line showing the lunching Installation loading

I successfully initiated launch instance (i-09b4851scf7fb49c2)

3. Connecting to EC2 Using GitBash

Once my instance was running, I connected to it from my computer:

EC2 Instance running, red arrow indicting EC2 name, blue arrow indicating EC2 Instanc ID, green arrow indicting EC2 Public IPv4 address

1.Retrieved the public IPv4 address from the AWS console.
IPv address-18.207.154.160

2.Opened GitBash (Command Prompt/PowerShell also works).
Type : cd downloads

Type cd downloads indicated by blue arrow

Type : chmod 400 my-2P-key.pem

Type chmod 400 my-2P-key.pem indicated by green arrow

3.Entered the SSH command:

ssh -i "C:\Users\Downloads\my-2P-key.pem" ubuntu@

ssh -i my-2P-key.pem ubuntu@18.207.254.160 indicated by red arrow

Example:
ssh -i my-2P-key.pem" ubuntu@18.207.154.160

4.Accepted the connection when prompted.

When the connection is been prompted, Type : yes

SSH is like a secure remote key that unlocks your apartment in the cloud and lets you control it.

4. Updating Ubuntu Server

Once inside the server, I updated its package list to ensure the latest software versions and security patches were available:

sudo apt update

Sudo apt update indicated by the red arrow while updating the package

This is like refreshing the app store on your phone before downloading or upgrading apps.

5. Installing and Configuring NGINX Web Server

With the server ready, I installed and configured NGINX:

Install NGINX:
sudo apt install nginx -y

Installing by typing Sudo apt install nginx -y

Start the NGINX service:
sudo systemctl start nginx

Starting by typing sudo system start nginx

Check if it is running:
sudo systemctl status nginx

Status is by typing sudo systemctl status nginx

Enable NGINX to start automatically on reboot:
sudo systemctl enable nginx

Enabling type sudo systemctl enable nginx

NGINX is now running and able to serve webpages from the server.

6. Testing and Customizing the Web Page

To test the installation, I opened my browser and typed:

http://

http://18.207.154.160

The tested customized web, using the IPv4 Address 18.207.154.160 on the open browser was indicted by the red arrow on a Google page searched

Welcome to NGINX !  was confirmed on the web browser because it worked showing it as default

This showed the default NGINX welcome page, confirming the web server was active.

Next, I customized the page:

1.Opened the default web file:
sudo nano /var/www/html/index.nginx-debian.html

2.Deleted the existing content using Ctrl + K.

3.Added my own message:

The Pharmatech logo is my NGINX web Server on AWS

4.Saved and exited by pressing Ctrl + X, then Y, then Enter.

Refreshing the browser displayed my new page. Editing this file was like changing the welcome sign on the front of a Pharmacy premise to make it personal.

  1. Full Quick Command Summary

Below are the main commands I used in this project:

sudo apt update
sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx
sudo nano /var/www/html/index.nginx-debian.html

GitBash SSH example:
ssh -i "C:\Users\John\Downloads\nginx-key.pem" ubuntu@18.207.154.160

Conclusion

This project gave me hands-on experience with launching and managing a cloud server. I learned how to:

Launch an EC2 instance on AWS.

Connect to it securely using SSH.

Install and configure NGINX on Ubuntu.

Edit and customize a web page.

It was more than just a technical exercise — it gave me a deeper understanding of how cloud infrastructure, Linux commands, and web servers work together in real-world scenarios.

Completing this project boosted my confidence in working with AWS, Linux, and NGINX, and it opened the door for me to build more advanced cloud-based projects in the future.

Top comments (0)