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)
âď¸ 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
â 2. Set Up a Security Group
This controls what kind of traffic can reach your instance.
- Allow SSH (port 22) for connection
đ 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)
đ 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
If this is your first SSH connection, it might ask you to confirm the fingerprint - just type yes.
đŚ 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
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
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
Once unzipped, copy the contents to Apacheâs web root and restart the service:
sudo cp -r * /var/www/html/
sudo systemctl restart apache2
đ Time to Visit the Site!
Open your browser and type:
But wait⌠page 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.
â 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đ.











Top comments (5)
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?
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. đ
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?
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.
Thanks!