Skip to main content

Command Palette

Search for a command to run...

πŸš€ Hosting Your First Website on AWS EC2 with Elastic IP

Published
β€’2 min read
πŸš€ Hosting Your First Website on AWS EC2 with Elastic IP
M

Hi, I’m Mohit Deore passionate about cloud computing, DevOps, and frontend technologies. I love building scalable applications and exploring new tools in the cloud and container ecosystem.

When I first started exploring AWS, I wanted to try something simple yet powerful: hosting my own website on an EC2 instance. In this blog, I’ll walk you through how I created a personal web server using EC2, Apache, and Elastic IP β€” all from scratch.

🌐 Hosting a Simple Website on AWS EC2 :

1 ) Launch an EC2 Instance

  • πŸ–₯️ Choose Amazon Linux 2 (Free Tier eligible).

  • ⚑ Instance type: t2.micro.

  • πŸ”‘ Download the key pair (.pem file).

2)Connect to the Instance using SSH

ssh -i your-key.pem ec2-user@<public-ip>

3)Install Apache Web Server (βœ… Apache will be now running)

sudo yum update -y
sudo yum install httpd -y
sudo systemctl start httpd
sudo systemctl enable httpd

4)Create a Simple HTML Page

echo "<h1>Hello from my EC2 Server πŸš€</h1>" | sudo tee /var/www/html/index.html

5)Update Security Group Rules

  • πŸ”’ Add inbound rule for HTTP (Port 80)

  • 🌍 Source: 0.0.0.0/0 (Anywhere).

6)Assign an Elastic IP

  • βš™οΈ Go to Elastic IPs β†’ Allocate new IP.

  • πŸ”— Associate it with your EC2 instance.

7)Access the Website

🌍 Open in browser:

http://<your-elastic-ip>

πŸŽ‰ Your site is live

⭐ Why Elastic IP is Better than Default Public IP

  • πŸ”„ Default public IP changes every time you stop/start the instance.

  • πŸ“Œ Elastic IP is static and stays permanent.

  • 🌐 Useful when hosting websites or mapping a custom domain.

More from this blog