# Hosting Your Website: Launching AWS EC2 Instance with Linux

1. Open the AWS Console using the link [**https://aws.amazon.com/console/**](https://aws.amazon.com/console/)**.**
    
2. ![](https://miro.medium.com/v2/resize:fit:700/1*DikCh2PHRsw_FSQYODq9gw.png align="left")
    
    Click on **Sign In to the Console**.
    
3. After signing up search **EC2** in the search bar.
    
    ![](https://miro.medium.com/v2/resize:fit:700/1*QKdZNf_d0vzYBCQoYkVLhA.png align="left")
    
4. Click on **EC2**. This window will open up.
    
    ![](https://miro.medium.com/v2/resize:fit:700/1*5QS_IBQE-xNKi0jO1eup-Q.png align="left")
    
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).
    
    ![](https://miro.medium.com/v2/resize:fit:700/1*gub_dVDVKnKImMqKon9RqA.png align="left")
    
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.
    
    ![](https://miro.medium.com/v2/resize:fit:588/1*_DOg4jN47l3SzjrZX9PvHw.png align="left")
    
10. Enable **Allow HTTPS traffic from the internet**, **Allow HTTP traffic from the internet**, and **Allow RDP traffic from** under network setting.
    
    ![](https://miro.medium.com/v2/resize:fit:700/1*1USoNdCcvJK1YbDpYP1GAg.png align="left")
    
11. Scroll down and click on **Launch Instance**.
    
12. A new page will open up. Click on the **instance**.
    
    ![](https://miro.medium.com/v2/resize:fit:700/1*bZoy9VOOcOoAcbaR7CTwGg.png align="left")
    
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**.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1722021581548/bdfc12d0-10d4-4adb-bc7a-e81e53e9079f.avif align="center")
    
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.
    
    ```bash
    sudo su
    yum update -y
    yum install httpd -y
    ```
    
19. Type the following to check the status of https currently it may be inactive.
    
    ```bash
    systemctl status httpd
    ```
    
20. Type the following command to activate httpd.
    
    ```bash
    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.
    
    ```bash
    cd /var/www/html
    ```
    
23. Enter the following command to create the index.html file and enter its content.
    
    ```bash
    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.
    
    ```bash
    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.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1722021628565/9966d09c-2c9e-49a6-8e41-f549cfe5c654.avif align="center")
    
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.
