DEV Community

Cover image for How I Deployed My Ubuntu EC2 Instance with NGINX and Customized My Web Page
Morodolu Oluwafikunayomi
Morodolu Oluwafikunayomi

Posted on

How I Deployed My Ubuntu EC2 Instance with NGINX and Customized My Web Page

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

Image description

  • AMI: Ubuntu Server 22.04 LTS (HVM), 64-bit
  • Instance Type: t2.micro (Free tier eligible)

Image description

Image description

Key Pair:

  • Choose an existing key pair or create a new one (download the .pem file).

Image description
or

Image description

  • Network Settings:
  • Allow SSH (port 22) and HTTP (port 80) in the security group rules.

Image description

  • Click Launch Instance.

Image description

  • In the instance page click on the instance id

Image description

  • Copy the public IPv4 address.

Image description

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
Enter fullscreen mode Exit fullscreen mode
  • Connect via SSH:
ssh -i "your-key-name.pem" ubuntu@<your-public-ip>
Enter fullscreen mode Exit fullscreen mode

Example:

ssh -i "nginx-key.pem" [email protected]
Enter fullscreen mode Exit fullscreen mode

If you get a permission error on the .pem file, run:

chmod 400 nginx-key.pem

Enter fullscreen mode Exit fullscreen mode

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.

Image description
Step 3: Install NGINX

  • Once inside your EC2 terminal:
sudo apt update
sudo apt install nginx -y
Enter fullscreen mode Exit fullscreen mode

Image description

Image description

  • Start and enable the service:
sudo systemctl start nginx
sudo systemctl enable nginx
Enter fullscreen mode Exit fullscreen mode

Image description

Step 4: Customize the NGINX Web Page:

  • Edit the default NGINX web page:
sudo nano /var/www/html/index.nginx-debian.html
Enter fullscreen mode Exit fullscreen mode
  • After typing the above it should show this:

Image description

  • 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>
Enter fullscreen mode Exit fullscreen mode

Image description

Step 5: Test in a Browser

  • Open your browser.
  • Type in your EC2 public IP. Example:
_http://18.207.203.209_
Enter fullscreen mode Exit fullscreen mode
  • You should see the custom NGINX page with your name and today’s date. Image description

Top comments (0)