Deploy An EC2 Instance On AWS and Install Nginx
Published: 2024-01-15 07:03:42

## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tzj3b4xa0zudaxtv4smt.png)





**Step 2 :**


Locate Ec2 on the homepage using the search bar


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gwbc2nqv0e7vr7ns8wvq.png)






**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/de9t2aclhkgaliqrsn7f.png)





**Step 4:**


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




![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xuqfb23ugma6bo69s74v.png)



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/co8i1of7ksy41uf65cm9.png)



**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q4czcgaanjtoadcykqr0.png)



**Step 6:**

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



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eko6i0gwi0n7gtofm44y.png)






**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zapssnt77bi7v9dekly3.png)



**Step 8:**

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7r4oxw5xn8tmue66rdlq.png)



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/joxwueltgs7cq4wva9kc.png)


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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c6nhnlw5d69bmt573z59.png)


**Step 10:** 

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




![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k3fsbxqymxxuwda4j8u0.png)



_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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k2n07t5ojq41exsl2n9p.png)




**Step 12:** 

Proceed to install nginx with the command `apt install nginx`


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ags513avxi2cuyqz0p3.png)



**Step 13:**

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b4hq1clth8t9kbht2wau.png)


**Step 14:** 

If not accessible, you get this


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s1d7wc6iu9l10kgb8uun.png)



**Step 15:**


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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/adlpzscztlbtqxuy5zju.png)



**Step 16:**

Proceed to edit **Inbound rules**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lmnohseoe35xedb8nzm4.png)



**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0yfivco4a93ti36vinoj.png)






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