"How to Launch a Website on AWS: Configuring a VPC and EC2 Instance"

051_muhammadshahbaz_2823

Muhammad Shahbaz

Posted on August 11, 2024

"How to Launch a Website on AWS: Configuring a VPC and EC2 Instance"

Image description

  1. Create a VPC Go to the VPC Dashboard in the AWS Management Console. Click on Create VPC.

Image description

Choose VPC only.
Provide a Name and CIDR Block (e.g., 10.0.0.0/26).

Image description

Select Tenancy as default.
Click on Create VPC.

Image description

  1. Create Subnet After creating the VPC, navigate to Subnets. Click on Create Subnet.

Image description

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.

Image description
subnet successfully created

Image description

  1. Create and Attach an Internet Gateway Go to Internet Gateways. Click on Create Internet Gateway. Provide a Name.

Image description

After creation, Attach the Internet Gateway to your VPC

Image description

  1. Update Route Table create Route Tables.

Image description
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.

Image description

  1. 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.

Image description

  1. 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.

Image description

  1. 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.

Image description

  1. 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!"

Image description
there is no load of website because its run upon https just remove s from https

Image description
access fully hosting the website

đź’– đź’Ş đź™… đźš©
051_muhammadshahbaz_2823
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.

Related