DEV Community

Cover image for From Classroom to Command Line: Building My First Live Server with AWS EC2 and NGINX
Emidowojo
Emidowojo

Posted on

From Classroom to Command Line: Building My First Live Server with AWS EC2 and NGINX

Five years after my first attempt, I rejoined the HNG internship program—this time choosing the DevOps track. While I had explored DevOps through LinkedIn Learning courses, I remained trapped in tutorial hell, never quite taking the leap into practical application. The HNG internship presented the perfect opportunity to change that.

My journey began on a Tuesday with the first task landing in my inbox. Despite feeling daunted and exhausted from my day job, I was determined to succeed. After some initial research, I tackled the project head-on the next morning, temporarily setting aside my work responsibilities.

What I thought would be a quick task turned into an adventure through multiple cloud platforms. I started with Digital Ocean, where I successfully connected to SSH and installed NGINX. However, I hit a wall when trying to edit the HTML file—a mysterious password requirement that no combination of credentials could satisfy.

Frustrated but undeterred, I pivoted to AWS. While the experience was somewhat better, I still faced permission issues when trying to edit the HTML page. A brief attempt with Azure proved equally challenging. Through all this, I juggled work responsibilities and an empty stomach, but my determination never wavered.

After nearly giving up—and reminding myself that quitting wasn't in my nature—I made one final attempt with AWS. Success finally came the following day around 3 PM.

The Winning Process

Here's how I ultimately succeeded:

  1. Created an AWS EC2 Instance (Ubuntu Server 22.04 LTS) using the free tier t3.micro
  2. Generated a key pair named DevOpsKey (.pem file)
  3. Configured the security group to allow SSH (Port 22) from my IP and HTTP (Port 80) from anywhere
  4. Connected to the EC2 instance via SSH using:
cd ~/Desktop/projects
chmod 400 DevOpsKey.pem
ssh -i "DevOpsKey.pem" ubuntu@16.171.194.50
Enter fullscreen mode Exit fullscreen mode

Installed and configured NGINX:

sudo apt update && sudo apt upgrade -y
sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx
Enter fullscreen mode Exit fullscreen mode

Created a custom HTML page:

sudo nano /var/www/html/index.html
Enter fullscreen mode Exit fullscreen mode

Added my custom HTML:

<!DOCTYPE html>
<html>
<head>
    <title>DevOps Stage 0</title>
</head>
<body>
    <h1>Welcome to DevOps Stage 0 - [Emidowojo Opaluwa]/[Emidowojo]</h1>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

After saving the file (Ctrl + O, Enter, Ctrl + X), I visited http://16.171.194.50 and saw my custom message displayed proudly in the browser. Below is a screenshot of my custom message

While the journey was frustrating at times, it was incredibly rewarding. The hands-on experience taught me more than any tutorial could have. Here's to the remaining nine stages of this adventure! ✨

Image description

Top comments (0)