Skip to main content

Command Palette

Search for a command to run...

Hosting Your Website: Launching AWS EC2 Instance with Linux

Step-by-Step Guide to Launching a Linux EC2 Instance for Your Website

Updated
2 min read
Hosting Your Website: Launching AWS EC2 Instance with Linux
A
Associate Software Developer with experience building scalable, production-grade systems and backend services. Strong foundation in data structures, system design, and core computer science concepts, with a passion for learning new technologies and sharing practical engineering knowledge through writing.
  1. Open the AWS Console using the link https://aws.amazon.com/console/.

  2. Click on Sign In to the Console.

  3. After signing up search EC2 in the search bar.

  4. Click on EC2. This window will open up.

  5. Scroll down and Click on Launch Instances.

  6. Give a suitable name for the instance.

  7. Select AWS Linux under Application and OS Images (Amazon Machine Image).

  8. Scroll down to the Key pair.

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

  10. Enable Allow HTTPS traffic from the internet, Allow HTTP traffic from the internet, and Allow RDP traffic from under network setting.

  11. Scroll down and click on Launch Instance.

  12. A new page will open up. Click on the instance.

  13. Wait for 4–5 mins until the instance state is notrunning and the Status check is not 2/2 checks passed.

  14. Select the instance then click on Connect.

  15. Go to EC2 Instance Connect.

  16. Scroll down and click on Connect.

  17. A new tab will open up wait until the connection is established.

  18. Copy and paste the following commands one by one.

    sudo su
    yum update -y
    yum install httpd -y
    
  19. Type the following to check the status of https currently it may be inactive.

    systemctl status httpd
    
  20. Type the following command to activate httpd.

    systemctl active httpd
    
  21. Now check the status of httpd it must be active.

  22. Type the following command to get to the directory when the index.html must be stored in hosting.

    cd /var/www/html
    
  23. Enter the following command to create the index.html file and enter its content.

    cat > index.html
    
  24. Now enter the content you want in index.html file. Then press the enter key.

  25. Press ctrl + d to save the file.

  26. You can check the saved content using the following command.

    cat index.html
    
  27. Go to the instance tab.

  28. Copy and paste the Public IPv4 address to a new browser window. Directly clicking on the open address may not work.

  29. The content written on index.html file should appear on the new window.

  30. To terminate the instance, select the instance click on instance state, and then click on terminate instance.

AWS Training Chronicles: From Novice to Expert

Part 20 of 22

Follow my journey as I learn AWS from scratch, sharing insights, tips, and hands-on experiences along the way.

Up next

Hosting Your Website: Launching AWS EC2 Instance with Windows

Easy Steps to Install Windows Server on AWS EC2 for Website Hosting