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

Mohit DeoreMohit Deore
2 min read

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.

0
Subscribe to my newsletter

Read articles from Mohit Deore directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Mohit Deore
Mohit Deore