In this post, I’ll walk you through how I launched an Ubuntu EC2 instance on AWS, installed NGINX, customized the default web page to display my name and today’s date, and made it accessible via a public IP. I also include my terminal commands and relevant screenshots.
** What You’ll Need:**
- AWS Account
- A key pair (.pem file)
- PowerShell (or Git Bash) on Windows
Step 1:
- Launch a New Ubuntu EC2 Instance
- Go to the AWS EC2 Dashboard.
- - Click "Launch Instance".
Set:
- Name: nginx-demo
- AMI: Ubuntu Server 22.04 LTS (HVM), 64-bit
- Instance Type: t2.micro (Free tier eligible)
Key Pair:
- Choose an existing key pair or create a new one (download the .pem file).
- Network Settings:
- Allow SSH (port 22) and HTTP (port 80) in the security group rules.
- Click Launch Instance.
- In the instance page click on the instance id
- Copy the public IPv4 address.
Step 2: Connect to the EC2 Instance via PowerShell
- Open PowerShell or Git Bash.
- Navigate to the folder where your .pem file is:
cd Downloads
- Connect via SSH:
ssh -i "your-key-name.pem" ubuntu@<your-public-ip>
Example:
ssh -i "nginx-key.pem" [email protected]
If you get a permission error on the .pem file, run:
chmod 400 nginx-key.pem
The chmod 400 command in Linux is used to set the file permissions of a file or directory so that only the owner has read permissions, and everyone else has no permissions.
- Once inside your EC2 terminal:
sudo apt update
sudo apt install nginx -y
- Start and enable the service:
sudo systemctl start nginx
sudo systemctl enable nginx
Step 4: Customize the NGINX Web Page:
- Edit the default NGINX web page:
sudo nano /var/www/html/index.nginx-debian.html
- After typing the above it should show this:
- Replace the body with something like:
<!DOCTYPE html>
<html>
<head>
<title>Welcome</title>
</head>
<body>
<h1>Hello, I'm Oluwafikunayomi Morodolu</h1>
<p>Today's date is: 22nd June 2025</p>
</body>
</html>
Step 5: Test in a Browser
- Open your browser.
- Type in your EC2 public IP. Example:
_http://18.207.203.209_
- You should see the custom NGINX page with your name and today’s date.
Top comments (0)