AWS Builder Center
Deploying a Simple Web Server on Amazon EC2: A Beginner’s Hands-On Guide

Deploying a Simple Web Server on Amazon EC2: A Beginner’s Hands-On Guide

A beginner-friendly walkthrough of launching an Amazon EC2 instance, connecting securely through SSH, configuring a web server, and understanding the basic EC2 workflow.

Deploying a Simple Web Server on Amazon EC2: A Beginner’s Hands-On Guide

Amazon EC2 (Elastic Compute Cloud) is one of the core services of AWS. It allows us to create virtual servers in the cloud and configure them based on our requirements.
In this article, I’ll walk through the basic process of launching an EC2 instance, connecting to it using SSH, and understanding how a simple cloud server works.

What is Amazon EC2?

Amazon EC2 provides virtual machines called instances.
Instead of purchasing and maintaining a physical server, we can launch an EC2 instance within minutes and choose its:
  • Operating system
  • CPU and memory
  • Storage
  • Network configuration
  • Security settings
This makes EC2 useful for hosting websites, APIs, backend applications, development environments, and many other workloads.

Step 1: Launch an EC2 Instance

Open the AWS Management Console and navigate to:
EC2 → Instances → Launch instance
Give the instance a meaningful name.
For the operating system, I used:
Amazon Linux 2023
Next, select an appropriate instance type for your workload.
For learning and experimentation, a small instance type is usually enough.

Step 2: Create a Key Pair

AWS uses key pairs for secure SSH authentication.
While launching the instance, create or select a key pair.
The private key is downloaded as a .pem file.
For example:
1
my-ec2-key.pem
Keep this file secure because it is used to authenticate when connecting to the EC2 instance.

Step 3: Configure the Security Group

A security group acts like a virtual firewall for an EC2 instance.
For SSH access, allow:
1
2
SSH
Port: 22
If you are hosting a web application, you may also need:
1
2
HTTP
Port: 80
or
1
2
HTTPS
Port: 443
Security group rules should only allow the access that is actually required.

Step 4: Prepare the PEM File on Windows

When using SSH from Windows PowerShell, the private key should have restricted permissions.
For example:
1
2
icacls .\my-ec2-key.pem /inheritance:r
icacls .\my-ec2-key.pem /grant:r "$($env:USERNAME):(R)"
You can verify the permissions using:
1
icacls .\my-ec2-key.pem
This helps ensure that the SSH client accepts the private key.

Step 5: Connect to the EC2 Instance

Copy the public IPv4 address of the EC2 instance from the AWS console.
Then connect using SSH:
1
ssh -i my-ec2-key.pem ec2-user@YOUR_EC2_PUBLIC_IP
After authentication, the terminal connects directly to the Amazon Linux server.
You should see the Amazon Linux command-line environment.
At this point, you are controlling a remote computer running inside AWS.

Step 6: Update the Server

After connecting, update the available packages:
1
sudo dnf update -y
Keeping packages updated is an important part of maintaining a server.

Understanding What Just Happened

The overall workflow looks like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
My Computer
|
| SSH over Port 22
v
Internet
|
v
AWS Security Group
|
v
Amazon EC2 Instance
|
v
Amazon Linux
The EC2 instance runs in AWS infrastructure, while SSH provides secure remote access from the local computer.

Important EC2 Concepts I Learned

Instance

A virtual server running in AWS.

AMI

An Amazon Machine Image contains the operating system and initial configuration used to create an instance.

Instance Type

Defines the CPU, memory, networking capability, and other hardware resources available to the instance.

Key Pair

Used for secure authentication when connecting through SSH.

Security Group

Controls inbound and outbound network traffic for the instance.

Public IPv4 Address

Allows the instance to communicate with systems over the internet when correctly configured.

Stop Instances When They Are Not Needed

After completing experiments, instances should be stopped or terminated when they are no longer required.
Stopping an instance shuts down its compute resources while allowing it to be started again later.
Terminating an instance permanently deletes it.
This is particularly important while learning AWS because actively running resources may generate charges depending on the services and account configuration being used.

What I Learned

This hands-on exercise helped me understand that EC2 is more than simply creating a virtual machine.
It involves several cloud concepts working together:
1
2
3
4
5
6
7
8
9
Compute
+
Networking
+
Security
+
Storage
+
Remote Administration
Understanding these fundamentals makes it easier to move toward more advanced topics such as application deployment, load balancing, auto scaling, containers, and cloud architecture.

Conclusion

Amazon EC2 is a great starting point for understanding cloud infrastructure.
Launching an instance, configuring network access, and connecting through SSH provides practical experience with how cloud servers operate.
The best way to learn AWS is to combine theory with hands-on experimentation and gradually build more complete architectures.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article