How to host a static website in AWS EC2

I'm AWS Certified Solution Architect. I do write about the AWS Cloud Operation, Migration, Security and Automations.
Search for a command to run...

I'm AWS Certified Solution Architect. I do write about the AWS Cloud Operation, Migration, Security and Automations.
No comments yet. Be the first to comment.
Introduction: Migrating physical or virtual machines from on-premises to AWS can feel scary but AWS Application Migration Service (MGN) makes it straightforward by continuously replicating servers to AWS and enabling test launches and cutovers with m...

Migrating your on-premises MySQL database to Amazon RDS for MySQL with AWS Database Migration Service (DMS) is a common way to move to a managed, highly available database while keeping zero downtime or minimal. In this blog, I’ll show how you can mi...

Introduction: Monitoring storage utilization is critical to ensure application stability and avoid unexpected outages. In AWS, Amazon EBS does not provide built-in metrics for volume-level disk usage, which makes proactive alerting a challenge. To ad...

Introduction: we need to securely transfer sensitive documents to the cloud without manual intervention. A common requirement is to automatically detect file changes, apply client-side encryption, and upload only the modified files on a scheduled bas...

Introduction: Data migration and disaster recovery are key considerations for building resilient cloud architectures. A common requirement is to migrate data from an local machine to a primary Amazon S3 bucket, while ensuring that the same objects ar...

Amazon Elastic Compute Cloud (EC2) is a web service offered by Amazon Web Service (AWS) that provide scalable computing capacity in the cloud. EC2 allows users to launch virtual machines (instances) and run a wide range of applications on them.
Now let's create EC2 instance and Deploy our static website
(prerequisite: AWS account)
Step 1: Go to AWS Management Console and Search for EC2 instance also, click on it.

Step 2: Click on Launch Instance on the Dashboard.

Step 3: Write a name for the instance (example: MyWebServer). you can also give additional tags.

Step 4: Choose Amazon Linux 2 and Instance type t3.micro,
you can always choose as you want but Recommend you to use Free tier.


Step 5: Select "Create a new pair" and give a name for now say "webSarver".


you have to know where your key pair file is being downloaded.
Step 6: In the Network settings,
You can Configure the Security Group name and Description as you like but we are leaving it as default for now.
select the Inbound security groups rules you can see the Add security group rule click on it.



Step 7: In configure storage
leave it as default for now but you can get upto 30 GiB in the free tier. This will be your root volume also known as 'boot' volume.

Step 8: In configure advance details
add the following codes in the user data field and leave other field as default.

The Script does the following:
Install an Apache web server (httpd)
configure the webserver to automatically start on boot
Activate the Web server
Create a simple web page
Step 9: Click on Lauch instance

you can see this interface with a sucess.

step 10: Wait for some time the instance is running and the status is initializing. After some time you can see that there is 2/2 checked passed on the status check.


step 11: Now, you can click on the instance Id and copy the Public IPv4 address and paste it in the browser. you would be able to see this result which was written in the user data field inside the h1 tags.

That's all, you have finally hosted a static website on the AWS cloud.
Congratulations guys!!!