Creating EC2 Instance In AWS To Host A New Website

Sharon Johnson
4 min readFeb 11, 2023

--

Scenario: Your company wants to start shifting from using on premises servers to using servers in the cloud. Rather than purchasing all the infrastructure in a data center they ask you to create an EC2 instance in AWS to host their new website.

Objective:

1. Launch an EC2 Amazon Linux t2.micro (free tier) in a public subnet of your Default VPC.

2. Create a security group that allows inbound traffic on HTTP for 0.0.0.0/0 and allows inbound traffic on SSH from your IP address.

3. SSH into your EC2 instance and install Apache with a custom webpage using a BASH script.

First thing you will need to do is to open and create your AWS Console Management Account (you can visit YouTube for instructions).

Step 1: Launch EC2 Amazon Linux t.2 micro,

You will need to open up you AWS account, in the search bar type in EC2 , click on EC2, this will put you in the EC2 dashboard.

This is the EC2 Dashboard, navigate to the “Launch Instance Button”

Name your instance under “Name and Tags”

Under the Application and OS Images you can leave it set as default if you like or you can chose whatever system that will work for you, for this project I’m choosing the default settings

Keep the Instance Type as default t.2 micro

Now lets “Create New Key Pair” once you click on the create key pair you will need to name it then hit create key pair. When you click create key pair notice your key pair save at the bottom of your screen as a .pem file, make sure you save this file to your computer.

Step 2: Create a security group,

Under Network Settings under Firewall (security groups) make sure you select “Create security group” make sure “Allow SSH Traffic From” and “Allow HTTPS Traffic From The Internet” and “Allow HTTP Traffic From the Internet” is checked, click on the drop down arrow “Anywhere” and you can select “MY IP” (this will contain your IP address).

Example of what your inbound rule should look like

From here keep the default settings and we can Launch Instance

You should now see that the launch instance was successful

Step 3: SSH into your EC2 instance and install Apache and customize a webpage message using BASH script.

On the EC2 Dashboard now click on Connect to Instance, make sure you are on the SSH client tab

Now open up your SSH client, I will be using “PowerShell” for this project and follow the steps below

If you are seeing this you are on the right track

You might be prompt to run security updates if you see Run “sudo yum update”, type exactly that, sudo yum update, once the update complete you will be prompt “Is the ok”, type y (yes)

You have completed the updates.

Project is complete if you are seeing your script.

--

--

No responses yet