DEV Community

ODINKEMELU INNOCENT
ODINKEMELU INNOCENT

Posted on

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

INTRODUCTION

Getting started with cloud computing can feel overwhelming, but the best way to learn is by doing. In this project, I deployed my very first NGINX web server on Amazon Web Services (AWS) using an EC2 instance. The aim was to gain practical experience with cloud infrastructure while setting up a real-world web server.

This walkthrough is beginner-friendly and easy to follow, with step-by-step instructions. Alongside my explanation, I documented each stage with annotated screenshots to make the process clearer. By the end of this project, I successfully launched a virtual machine in AWS, connected to it using the command line, installed and configured NGINX, and customized a simple webpage.

  1. Introduction to Cloud Computing and AWS

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.

2.Navigated to Services > EC2 > Launch Instance.

3.Named the instance: nginx-webserver.

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

.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).

6.Created a new key pair called nginx-key and downloaded the .pem file.

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.

8.Clicked Launch Instance.

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.

  1. Connecting to EC2 Using Command Prompt

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

1.Retrieved the public IPv4 address from the AWS console.

2.Opened PowerShell (Command Prompt also works).

3.Entered the SSH command:

ssh -i "C:\Users\Downloads\nginx-key.pem" ubuntu@

Example:
ssh -i "C:\Users\John\Downloads\nginx-key.pem" ubuntu@3.90.20.10

4.Accepted the connection when prompted.

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

  1. 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

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

  1. Installing and Configuring NGINX Web Server

With the server ready, I installed and configured NGINX:

Install NGINX:
sudo apt install nginx -y

Start the NGINX service:
sudo systemctl start nginx

Check if it is running:
sudo systemctl status nginx

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

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

  1. Testing and Customizing the Web Page

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

http://

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:

Hello, World! This 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 restaurant 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

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

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)