Amazon EC2 instance is an Infrastruture as a Service(Iaas) in the cloud computing model. Amazon Elastic Compute provides resizeable compute capacity in the cloud. EC2 allows users to rent virtual machines, known as instances, and run applications on them.
These instances are available in various configurations, allowing users to choose the amount of virtual CPUs, memory, storage, and networking capacity that best suits their needs.
In the next few steps we will deploy an Ubuntu instance in EC2 ,and install nginx server.
PREREQUISITES:
To start ,we will need an aws account www.aws.amazon.com
.
Secondly is a Webterminal,for example GitBash in this exercise.
STEPS
1 Log into your console , on the search panel above type ec2 and select it from the drop-down menu.
2 In the window that opens after step 1 , select Launch Instance.
3 Provide a unique name for your EC2 virtual machine Hagital
,in the name and Tag section.
4 In the Application And OS Images,click on the browse more AMI and type Ubuntu in the search window.
5 Scroll down and select "Ubuntu Server 22.04 LTS (HVM), SSD Volume Type"
6 Scroll down , in the instance type leave as default t2.micro
free tier as shown .
7 Scroll down to key pair login section,and select create a new key pair. We will create a key pair to grant us access when we try SSH into th machine from our web terminal.
8 Provide a unique name for the key,and leave the remaining settings as default. Click on the create key button below. Your unique private key will download into your host machine.
9 In the Networking Settings, leave default to create security group selected.Select all checkboxes to "Allow SSh from","Allow HTTPS traffic from the Internet" , and "Allow HTTP traffic from the Internet".
10 We leave all other setting as default and click on the lauch Instance button to create the machine.
If suucessfully launched, we get the below message
USING A WEB TERMINAL TO ACCESS THE EC2 INSTANCE AND CREATING A WEBSERVER(nginx)
1 Click the hamburger icon on the left and select Instance. Select the instance created and it opens to a new window.
2 In the new window,click and select connect
3 We can connect using EC2 instance manager,Session Manager,SSH clent or EC2 serial console. we are using SSh client to connect.Select SSH client and follow the below steps to connect.
4 Open GitBash web terminal,and locate your private key downloaded ealier in the exercise. using the commant cd
. Our is located at the download folder.
5 Run this command, if necessary, to ensure your key is not publicly viewable.
chmod 400 "hagital-key-pair.pem"
6 Connect using the command below into your instance
"ssh -i "hagital-key-pair.pem" ubuntu@ec2-3-85-111-48.compute-1.amazonaws.com"
CONFIGURE NGINX WEBSERVER
1 run the command sudo su to get admin access
2 run apt update to upgrade the instance.
3 Install Nginx using the command apt install nginx.When prompted type yes and continue.
4 Verify the Ip address of your machine using the command :"Ip addr"
5
Copy the Ip Address an paste in a browser the see your newly created webserver.
In conclusion , Amazon Ec2 is widely used for various purposes including hosting of websites,running applications,processing data and more. It forms a fundamental building block of many AWS solutions and is a vital solution.
Top comments (0)