โ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
.pemfile - Security 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. ๐งก
Top comments (0)