Nginx WebServer on Ubuntu OS running via EC2 (AWS)
Tags: nginx, ubuntu, ec2, aws
Published: 2024-05-25 22:36:29

_Imagine you have a favorite game you like to play on your computer, but sometimes your computer might not be strong enough to run it well. Now, let's pretend there's a super strong computer far away that you can borrow to play your game. You can connect to this super strong computer from your own computer and play your game smoothly._

**Ubuntu** is like a special game or tool that people use on their computers to do a lot of important things. It's a**_ type of software called an operating system_**, _just like how Windows or macOS helps you use your computer._

**EC2, which stands for Elastic Compute Cloud**, is like that super strong computer you can borrow. _It's part of a big service called Amazon Web Services (AWS) that has lots of these strong computers all over the world._

So, when we say "**Ubuntu running on EC2**,"_ it means we're using that special tool (Ubuntu) on one of those super strong computers (EC2) far away_. This lets people do their important work or run their programs even if their own computer isn't strong enough. It's like playing your favorite game on a super strong computer somewhere else!

**Launch aws portal** 
![AWS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/blck9cchodc2fkdia3xn.png)
**Search and Select EC2**
![Search EC2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tfknu5rcspq3n5wjj0rv.png)
**On EC2 Dashboard, click instance**
![Launch EC2 instance](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2xbbjge05gr6ne3z69hn.png)
**Give your instance a name and select the appropriate Image**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/23690pea2mt60tunjx5l.png)
**Provide other parameters according to your need.**
![Key Pair](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g8h9coqob5595qa4w37c.png)
**Create a Key Pair**
**Ensure that you have a key pair**
![Create Key Pair](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fdp7attb5qf2rxl9fqc6.png)

![Key Pair Created](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lgorv61tduk9tvxy8xkq.png)

**To run a Nginx webserver, we need to allow HTTP traffic**
**Then , Launch Instance**

![Nginx](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/djpxtd0s1407kq96tu73.png)
**Connect to Instance**
![Ubuntu Running](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y47poiu212pinu8o2wgo.png)
**Select Connect**
![Connect](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ocyzzbpr8mwbiqtlvrhf.png)

![running instance](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ynoidcliax2vgd8s9stb.png)

![From EC2 Portal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vzlvt1xvf849o11z54tr.png)

**Access your instance locally**
_Launch Powershell_

![PowerShell](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5qmytsh7caahtivq3n22.png)

![Ubuntu Login](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/harblil96e26k5qydh8o.png)

![Ubuntu](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/npzqml8j8zktnl5soccl.png)
**Change privilege to root**
`sudo su`
**Install Nginx with the code**
`apt install nginx -y`
**Verify Nginx is installed**
`nginx --version`

![nginx](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n4r4w1bxi95l627oondi.png)
**Validate that nginx is running on webserver using Public IP**
![Public IP](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jebq8cd3bwefmfw68zyu.png)