Using AWS Web Console to Create Your First Web Server on AWS

EC2 or Elastic Compute Cloud is the commercial name for the virtual machine you can use in AWS cloud service.

We are going to create a machine using the web console.

Our goal is to create a web server using Nginx. This is a quick start, some concepts will be detailed in the next sections if this course.

You need to go to aws.amazon.com and type your login and password.

Note that in this part of the training, I am using the AWS default VPC. If you already deleted it, you can restore it by going to your VPC configuration, then create a new one:

Default VPC

You can find the link to access EC2 under the Compute menu, or you can search for it by simply typing “ec2”.
EC2 on AWS

Now you should choose the region you want to use for your EC2 virtual machine.

I used to use Ireland as a region since it is the cheapest nearest region to me. This may not be the case for you but you can see more details on pricing here.

AWS Regions

Click on “Launch Instance”:

Creating an AWS Instance

This will take you to this screen where you should choose the operating system to use:

Choosing you AMI

I am going to use Ubuntu, choose your own OS and click on “Select”. You will be redirected to the second screen where you should use the machine size.

Choosing your Instance Type

Now you can use the t2.micro instance (Free tier eligible).

After clicking on “Next”, you will be asked to provide the configuration for your virtual machine. Keep everything as it is and enable “Auto-assign Public IP”.

Choosing your Instance Details

Click on “Add Storage”. Keep everything as it is for the moment and click on “Add Tags”.

Click on “click to add a Name tag” and add aws-tutorial as “Name”.

Adding EC2 Tags

Choose “Next” and click on “Create a new security group”, add a security group name (I name it “aws-tutorial-sg”) and the description you want (add a description that will help you to remember why this security group was created), then allow SSH, HTTP & HTTPS from everywhere:

Configuring the Security Group

In “source”, choose “custom” and add

0.0.0.0/0

Click on “Review and Launch” then on “Launch”. If this is the first time you’ll use AWS and EC2, you will be asked to create a key pair that will allow us to ssh into the created machine.

Creating a Keypair

Give your key pair a name and download it to keep it in a safe place.

I usually move this to my home folder and this is what I am going to do in this tutorial.

When you finish downloading the key pair, you can click on “Launch Instances” then on “View Instances”.

Vewing the Created EC2 Machine

Wait for the initialization to finish and right-click on the instance, then click on “Connect”. You will see this screen with the SSH command you should use in order to get into the machine.

If you are using Linux, Mac OS or Ubuntu on Windows you can use your terminal with the given command.

If you are using Windows, Putty is a known and widely used SSH client that you can use but we recommend using Bash.

The command used to SSH into the machine looks similar to this:

ssh -i "aws-tutorial.pem" ubuntu@ec2-34-253-210-158.eu-west-1.compute.amazonaws.com

Every OS has a default username that should be used. Here is a list of some of them:

Distribution Ssh Username
Amazon Linux ec2-user
Ubuntu ubuntu
Debian admin
RHEL 6.4 & later ec2-user

I moved the key pair from my “Download” folder to my “Home ” folder and I executed the command given by AWS connection popup.

You can probably get an error message similar to this one:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'aws-tutorial.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "aws-tutorial.pem": bad permissions
Permission denied (publickey).

This is a permission problem that could be fixed using chmod:

chmod 0400 aws-tutorial.pem

Once we made an SSH into the created machine, we can start installing Nginx:

sudo apt-get update && sudo apt-get install -y nginx

Now let’s get back to the console and check the public IP address that our machine is using. We can see this is the web dashboard:

EC2 Configuration

Our public IP is

34.253.210.158

When typing this in my browser, I can see that Nginx was successfully installed:

Nginx Welcome Page

You can do the same using the IP address that AWS assigned to your virtual machine and check if everything is working fine!

Tags:

No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Comments