DEV Community

Cover image for Deploy An EC2 Instance On AWS and Install Nginx
Tolulope Adeleke
Tolulope Adeleke

Posted on

Deploy An EC2 Instance On AWS and Install Nginx

What is Aws Ec2 instance ?

Amazon EC2 (Elastic Compute Cloud) is a web service provided by Amazon Web Services (AWS) that allows users to rent virtual servers in the cloud. These virtual servers are known as "instances." EC2 instances provide scalable computing capacity, allowing users to quickly scale up or down based on their computing requirements.

Some of the key features of Ec2 includes Scalability, pricing options, security, elastic load balancing, etc.

Let's deploy ec2 instance on AWS using the following steps;

Step 1:

Log into your AWS Console and change your region, I will be using US East 2.

Image description

Step 2 :

Locate Ec2 on the homepage using the search bar

Image description

Step 3:

You either click on instance on the resource page, then go ahead to launch instance on the next page. On launch instance immediately using the launch Instance button

Image description

Step 4:

Once you click the launch Instance button, choose a name and add a new tag

Image description

Image description

Step 5:

Proceed to pick the image to work with. For this, we will be making use of Ubuntu.

Ubuntu is the modern, open source operating system on Linux

Image description

Step 6:

Choose an Instance type. we will make use of the default Instance type.

Image description

Step 7:
Create a key pair. choose the RSA key pair type and Pem private key format, download and save in a folder.

Image description

Step 8:

Proceed to launch Instance... Give it few seconds and wait for the notification Successfully Launched.

Image description

Image description

Step 9:
Go back to view instances, select the Instances just created and connect.

Image description

Step 10:

we connect using EC2 Instance connect. Make sure to take note of the username and copy the Public IP address.

Image description

Once connected, you proceed to run commands that will give way to installing Nginx

Step 11:

The first command to run is Sudo su this is because we need to be on root to install nginx. Then confirm that everything is updated by running the command apt update

Image description

Step 12:

Proceed to install nginx with the command apt install nginx

Image description

Step 13:

Proceed to check if DNS is accessible.Go back to Instance deatails to copy and paste on your web browswer

Image description

Step 14:

If not accessible, you get this

Image description

Step 15:

Move to security groups from the panel, select the group ID of the Instance just created.

Image description

Step 16:

Proceed to edit Inbound rules

Image description

Step 17: Add a new rule. Type : HTTP (not HTTPS)
source: Anywhere Ip4

Then proceed to save rule

Step 18: check DNS accessibility again using the Public IPv4 DNS or reload previous page.

Image description

Well done Mate ! You have succesfully deployed AWS Ec2 Instance and installed Nginx.

Top comments (0)