DEV Community

Cover image for 🚀 Hosting a Static Website on AWS EC2 -My First Step Toward DevOps
Oluwaseyi Asowo
Oluwaseyi Asowo

Posted on

4 3 3 3 3

🚀 Hosting a Static Website on AWS EC2 -My First Step Toward DevOps

Hey there! I'm Oluwaseyi - a System Administrator who’s passionate about all things cloud. Lately, I've been diving deep into the world of DevOps, and I thought, what better way to document this journey than to share what I’m learning?

This post is a practical walkthrough of how to host a static website on an AWS EC2 instance. Whether you're trying to understand the basics or just want to throw a simple portfolio online, this one’s for you.

So… ready to deploy your first site on the cloud? Let’s roll.


🧰 What You’ll Need

Here’s what you’ll need to follow along:

  • An AWS account (Free Tier is fine)
  • Terminal (Bash or Git Bash on Windows)
  • A static website (you can grab one from Tooplate - they’ve got nice free templates, or just use your own creation)

Tooplate

⛏️ Prepping Before We Launch the Instance

Before firing up the EC2 instance, there are two things we need to set up:

✅ 1. Create a Key Pair

You’ll use this to SSH into the instance. From your AWS EC2 dashboard:

  • Go to Key Pairs
  • Create new
  • Download the .pem file and store it safely - you’ll need it soon

Key Pairs

✅ 2. Set Up a Security Group

This controls what kind of traffic can reach your instance.

  • Allow SSH (port 22) for connection

Security Groups


🚀 Launch Your EC2 Instance

Now let’s spin up the machine.

  • Choose Amazon Linux 2 or Ubuntu (I'll be using Ubuntu for this guide - it doesn’t matter much for static sites)
  • Select t2.micro - Free Tier Eligible
  • During setup, make sure to:
    • Select the security group and key pair you just created
    • Download the key pair if you haven’t already (you won’t get another chance)

instance type

Security group


🔌 Connecting to Your EC2 via SSH

Now, open your terminal and navigate to the folder where your .pem key file is saved. Then connect using this format: ssh -i your-key.pem ubuntu@[your-ec2-public-ip]

ssh -i "web01.pem" ubuntu@18.204.197.240

Enter fullscreen mode Exit fullscreen mode

If this is your first SSH connection, it might ask you to confirm the fingerprint - just type yes.

terminal showing successful ssh connection


📦 Install Required Packages

Once you're in the EC2 shell, let's install a few packages we need:

sudo apt update
sudo apt install apache2 wget unzip -y

Enter fullscreen mode Exit fullscreen mode

That gives us a web server (Apache), and tools to download and extract our template.


📁 Set Up the Static Website

We’re going to grab a template from Tooplate and deploy it.

Create a temporary directory:

mkdir /tmp/webfiles
cd /tmp/webfiles

Enter fullscreen mode Exit fullscreen mode

Now go to Tooplate, pick any template, and copy the direct download link.

Back in your EC2 terminal:

wget https://www.tooplate.com/zip-templates/2132_clean_work.zip
unzip 2132_clean_work.zip
Enter fullscreen mode Exit fullscreen mode

wget

Once unzipped, copy the contents to Apache’s web root and restart the service:

sudo cp -r * /var/www/html/
sudo systemctl restart apache2

Enter fullscreen mode Exit fullscreen mode

🌐 Time to Visit the Site!

Open your browser and type:

public ip

But wait… page not responding?

not responding

Yeah, that’s because our security group didn’t initially allow HTTP traffic. So let’s fix that.

  • Head back to your AWS console
  • Go to Security Groups > Inbound rules
  • Edit and add HTTP (port 80)
  • Save, and refresh the browser

Boom! Your site should be live.

http

refresh

✅ Wrap Up

Congrats, you've just deployed a static site to AWS EC2! 🎉

It’s a small step, but a huge part of understanding how cloud hosting works under the hood. As I continue down this DevOps path, I’ll be sharing more tutorials, real-world use cases, and the bumps along the way.

Follow along if you want to grow your cloud confidence one project at a time. and oh, by the way don't forget to clean up your instance when you're done😁.

ACI image

ACI.dev: Best Open-Source Composio Alternative (AI Agent Tooling)

100% open-source tool-use platform (backend, dev portal, integration library, SDK/MCP) that connects your AI agents to 600+ tools with multi-tenant auth, granular permissions, and access through direct function calling or a unified MCP server.

Star our GitHub!

Top comments (5)

Collapse
 
nevodavid profile image
Nevo David

Pretty cool seeing stuff broken down like this, makes me actually wanna try it myself - you think setting up things from scratch teaches more than using managed services?

Collapse
 
bluezeus profile image
Oluwaseyi Asowo

Oh, 100% There’s something satisfying about building things from scratch, like putting together a puzzle where you actually learn what every piece does. Managed services are great when you need to move fast, but nothing beats the "aha!" moments (and occasional frustration😅) of setting things up yourself. But totally worth it for the learning alone.

But hey, when things break, because they will, you’ll know exactly how to fix them. 😉

Collapse
 
funmilola profile image
Funmilola

Great walkthrough! Just deployed my first static site too—this post helped solidify a few things.. What made you choose EC2 over other static site options like Netlify or Vercel?

Collapse
 
bluezeus profile image
Oluwaseyi Asowo

EC2 was for learning AWS and customization, but Netlify/Vercel are also good for most static sites. simpler, faster, and with built-in CDN. But if you’re exploring AWS or need fine grained control, EC2 is a fun (if overkill) learning project.

Collapse
 
funmilola profile image
Funmilola

Thanks!

ITRS image

See What Users Experience in The Browser — Anywhere, Anytime

Simulate logins, checkouts, and payments on SaaS, APIs, and internal apps. Catch issues early, baseline web performance, and stay ahead of incidents. Easily record user journeys right from your browser.

Start Free Trial