Deploy your first hello world application on AWS EC2 Instance

Rohit Jain
3 min readJul 16, 2023

--

Aws Ec2 Instance

Prerequisite:- AWS Account

Step1: — Create An EC2 Instance

  1. Open AWS Console and search EC2 on the search bar
  2. Navigate to the Ec2 dashboard and open the instance from the sidebar
  3. Click on the Launch Instance button

6. Enter the name of your instance

7. Then select the AMI (Amazon machine image) (Currently I am using a free tier account that’s why I have the AMI which is available in the free tier)

8. Choose the instance type, I am choosing t2.micro because it is in the free tier

9. Select the default value of key pair. It is required when you use CLI to connect to your EC2 instance. But today we are not using the CLI instead we will use EC2 connect.

10. In the Network setting, Allow the HTTP request, This will allow HTTP traffic to come into your application.

11. (Optional) You can also use the existing security group, but make sure that the inbound rules should be proper.

12. Now do not change any other settings and click on the Launch Instance button. It will take 1–2 min time to create your instance.

Step 2- Connect your instance with EC2 connect

  1. Select your instance and click on connect button

2. Select EC2 to connect and then click on connect button, this will open a terminal where you can write your Linux commands.

3. We are using an Apache server in this tutorial so for that we need to install httpd to run apache server. httpd is Produced by Apache Foundation and it is a piece of software that listens for network requests and responds to them

sudo su
yum update -y
yum install httpd

Now start and enable the httpd

systemctl start httpd
systemctl enable httpd

This command will create a directory /var/www/html. It is the default root folder of the web server. Before creating our HTML file first we need to change the ownership of this folder

chown -R $USER /var/www/html

Now enter your content in /var/www/html/index.html

echo "<h1>Hello World</h1>" > /var/www/html/index.html

Now go to the instances page -> select your instance -> open the public IPv4 DNS of your instance in the browser.

Congratulation, you have deployed your first hello world application on the EC2 instance.

In my next Blog, I will teach you how you can deploy a real-world application which you have built in React.Js. Stay tuned with me.

If you have any queries then connect me on LinkedIn, and I will help you there.

LinkedIn Profile link:- https://www.linkedin.com/in/rohitjain0301/

Thank you.

--

--