β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
file - 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)