๐ Hosting Your First Website on AWS EC2 with Elastic IP


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.
Subscribe to my newsletter
Read articles from Mohit Deore directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
