Hosting Your Website: Launching AWS EC2 Instance with Linux
Step-by-Step Guide to Launching a Linux EC2 Instance for Your Website
Open the AWS Console using the link aws.amazon.com/console.
-
Click on Sign In to the Console.
After signing up search EC2 in the search bar.
Click on EC2. This window will open up.
Scroll down and Click on Launch Instances.
Give a suitable name for the instance.
Select AWS Linux under Application and OS Images (Amazon Machine Image).
Scroll down to the Key pair.
Select any key pair from the drop-down if previously made otherwise click on Create new key pair and Enter the key name, Select Key pair type RSA then click on .pem under Private key file format then click on Create key pair. The key file will start downloading.
Enable Allow HTTPS traffic from the internet, Allow HTTP traffic from the internet, and Allow RDP traffic from under network setting.
Scroll down and click on Launch Instance.
A new page will open up. Click on the instance.
Wait for 4–5 mins until the instance state is notrunning and the Status check is not 2/2 checks passed.
Select the instance then click on Connect.
Go to EC2 Instance Connect.
Scroll down and click on Connect.
A new tab will open up wait until the connection is established.
Copy and paste the following commands one by one.
sudo su yum update -y yum install httpd -y
Type the following to check the status of https currently it may be inactive.
systemctl status httpd
Type the following command to activate httpd.
systemctl active httpd
Now check the status of httpd it must be active.
Type the following command to get to the directory when the index.html must be stored in hosting.
cd /var/www/html
Enter the following command to create the index.html file and enter its content.
cat > index.html
Now enter the content you want in index.html file. Then press the enter key.
Press ctrl + d to save the file.
You can check the saved content using the following command.
cat index.html
Go to the instance tab.
Copy and paste the Public IPv4 address to a new browser window. Directly clicking on the open address may not work.
The content written on index.html file should appear on the new window.
To terminate the instance, select the instance click on instance state, and then click on terminate instance.