"How to Launch a Website on AWS: Configuring a VPC and EC2 Instance"
Muhammad Shahbaz
Posted on August 11, 2024
- Create a VPC Go to the VPC Dashboard in the AWS Management Console. Click on Create VPC.
Choose VPC only.
Provide a Name and CIDR Block (e.g., 10.0.0.0/26).
Select Tenancy as default.
Click on Create VPC.
- Create Subnet After creating the VPC, navigate to Subnets. Click on Create Subnet.
Select the VPC you just created.
Provide a Name and CIDR Block (e.g., 10.0.1.0/24).
Specify the Availability Zone.
Click on Create Subnet.
- Create and Attach an Internet Gateway Go to Internet Gateways. Click on Create Internet Gateway. Provide a Name.
After creation, Attach the Internet Gateway to your VPC
- Update Route Table create Route Tables.
Select the route table associated with your VPC.
Add a new route:
Destination: 0.0.0.0/0
Target: The Internet Gateway you just attached.
Save the route.
- Launch an EC2 Instance Go to the EC2 Dashboard. Click on Launch Instance. Select Amazon Linux 2023 as the OS. Choose the instance type (e.g., t2.micro). In Network Settings: Select the VPC and Subnet you created earlier. Enable Auto-assign Public IP.
- Configure Security Group In the same wizard, under Security Group, create a new security group. Add the following rules: HTTP: Port 80, Source 0.0.0.0/0.
Review and launch the instance.
- Add User Data Script
Under the Advanced Details section, add the following script in the User Data field:
bash
Copy code
#!/bin/bash
yum update -y
yum install -y httpd
systemctl start httpd
systemctl enable httpd
echo "
Welcome to My Website!
" > /var/www/html/index.html This script installs Apache, starts the web server, and creates a simple HTML file.
- Launch and Access the Website Complete the wizard and launch the instance. Once the instance is running, obtain its Public IP from the EC2 Dashboard. Open a web browser and enter the Public IP (e.g., http://). You should see the message "Welcome to My Website!"
there is no load of website because its run upon https just remove s from https
đź’– đź’Ş đź™… đźš©
Muhammad Shahbaz
Posted on August 11, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.