How to host a static website in an EC2 instance?

We need to go through the following steps to host a static website in an EC2 instance in AWS Cloud. The steps are as follows:

  1. Install the HTTPD package in the linux instance.

No alt text provided for this image

2. To configure a HTML website, we need to go to a HTML folder where we can configure/manage the files. The command is:

cd /var/www/html

No alt text provided for this image

3. Create a new file named index.html by typing : vi index.html.

Go to insert mode by pressing 'i' and add some content in the file. Exit from the file once the content is added by typing Esc+shift+:+wq.



No alt text provided for this image

4. Start and enable the httpd service by typing the command:

systemctl start httpd

systemctl enable httpd.

No alt text provided for this image

5. Go to the instance settings and open the security tab.

Click on Edit Inbound Rules-> Add a rule for the protocol HTTP(Port 80) and allow access for anywhere IPV4.

No alt text provided for this image

6. Open a new tab on Google chrome and paste the EC2 instance public IPV4 address and mention the file name as follows:

<IP-Address>/<file name.html>

No alt text provided for this image

A static website on an EC2 instance using the Apache Server(HTTPD package) is hosted successfully.





To view or add a comment, sign in

More articles by Aditya Jogwar

  • Terraform Learnings

    I would like to share my further terraform learnings in this blog. If we do not want to delete all the resources which…

  • Terraform Learnings Day 2

    I would like to share some more information about terraform. HOW TO CHOOSE THE RIGHT INFRASTRUCTURE AS A CODE TOOL? The…

  • Terraform Learnings

    I would like to list my terraform day 1 learnings along with the detailed explanations of all the points. Terraform is…

  • How to configure EFS with an EC2 instance in AWS Cloud?

    Before starting the procedure on how to configure EFS, let's have some look at what is EFS? EFS is known as Elastic…

  • How to host a static website on AWS S3?

    What is AWS S3? AWS Cloud has a serverless service available popularly known as S3(Simple Storage Service). It is a…

  • How to create a mail server using Lambda, API Gateway and SES service of AWS?

    Here are the steps mentioned on how to configure a mail server using AWS serverless services such as Lambda, API…

Explore content categories