Deploy a Full Website on EC2 with Apache/Nginx (Using AWS Free Tier) 🚀

“Can I host a full-blown website on AWS... for free?”
YES, you can — and today I’ll show you exactly how to do it using EC2, Apache or Nginx, and zero jargon. Let’s go from idea to live website in under 30 minutes. 💡💻
🧠 Why Use EC2 to Host a Website?
Think of EC2 like renting a house (server) where you can host anything — your website, backend, or portfolio. You get full control, root access, and scalability.
Real-world analogy: EC2 is like leasing your own plot of land (server) in the cloud, and Apache/Nginx is the building you construct on top to serve guests (visitors).
And with the AWS Free Tier, your first 750 hours/month (t2.micro instance) are completely free for 12 months. 🎉
🧰 What You’ll Need
An AWS account (Free Tier enabled)
A simple website (HTML/CSS/JS files)
Basic terminal skills (copy-paste works too!)
🏗 Step-by-Step: Launch Your EC2 Instance
1. Go to the EC2 Dashboard
2. Launch a New Instance
Name: my-website-server
AMI: Amazon Linux 2 (or Ubuntu)
Instance Type: t2.micro (Free Tier)
Key Pair: Create new one, download
.pem
fileSecurity Group: Allow ports 22 (SSH), 80 (HTTP), and optionally 443 (HTTPS)
3. Launch and Connect
Once it’s running, click “Connect” and follow the instructions for SSH:
chmod 400 my-key.pem
ssh -i my-key.pem ec2-user@<your-ec2-ip>
🔧 Install Apache or Nginx
Choose one:
Option A: Install Apache
sudo yum update -y
sudo yum install httpd -y
sudo systemctl start httpd
sudo systemctl enable httpd
Visit http://<your-ec2-ip>
— you’ll see the Apache test page 🎉
Option B: Install Nginx (Ubuntu example)
sudo apt update
sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx
Now go to your EC2 IP in the browser — Nginx is live!
📁 Upload and Host Your Website
1. Replace Default Files
cd /var/www/html # Apache
cd /var/www/ # Nginx (usually /var/www/html or /usr/share/nginx/html)
2. Create an index.html
echo "<h1>My EC2 Website is Live! 🚀</h1>" | sudo tee index.html
3. Or Upload Your Site Files
Use scp
(from your local machine):
scp -i my-key.pem * ec2-user@<your-ec2-ip>:/var/www/html/
🌍 Optional: Add a Custom Domain (Bonus)
Buy a domain from GoDaddy, Namecheap, etc.
Point your domain’s A record to your EC2 public IP
BOOM — your website is live with your domain 🚀
Want HTTPS? You can install a free SSL using Let’s Encrypt + Certbot (ask in comments and I’ll write a full guide!)
🧠 Quick Recap
Step | What You Did |
1️⃣ | Launched an EC2 instance on Free Tier |
2️⃣ | Installed Apache or Nginx to serve content |
3️⃣ | Uploaded website files to /var/www/html/ |
4️⃣ | (Optional) Mapped a domain to your site |
You now have a fully deployed, production-ready static site running in the cloud 💪
🙌 Final Thoughts
There’s something empowering about deploying your own website using real servers.
You’re not just learning AWS—you’re building confidence as a developer.
Want to go further? Add SSL, host a blog, or automate deployments with CI/CD.
💬 Your Turn!
Did this guide help you go live on EC2? What did you deploy — a portfolio, a side project, or a meme site? 😄
👇 Drop a comment, smash ❤️ if this saved you hours, and share with someone ready to ditch shared hosting forever!
Let’s build cool things in the cloud — together. 🧡
Subscribe to my newsletter
Read articles from Yash Sonawane directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Yash Sonawane
Yash Sonawane
DevOps & Cloud Engineer | AWS, Docker, K8s, CI/CD Writing beginner-friendly blogs to simplify DevOps for everyone.