Build and Deploy Your First Website on AWS EC2: A Step-by-Step Guide
A beginner-friendly guide to understanding cloud servers, configuring a web server, and making a simple website accessible over the internet.
Introduction
When I started exploring AWS, one question came to mind: How does a website actually run on a cloud server?
We use websites every day, but behind each website there is infrastructure that receives requests, processes them, and sends responses back to users. Cloud computing makes it possible to run this infrastructure without maintaining a physical server ourselves.
In this article, I will walk through a beginner-friendly example of hosting a simple website on Amazon Web Services (AWS) using Amazon EC2.
The goal is to understand the basic deployment process, learn a few important AWS concepts, and see how a website can be made accessible through the internet.
You do not need advanced cloud knowledge to follow the concepts in this guide.
1. What Are We Going to Build?
We will deploy a simple static webpage on an Amazon EC2 instance.
Our project will use:
- Amazon EC2: To provide a virtual server.
- Amazon Linux 2023: The operating system running on the server.
- Nginx: A web server that delivers our webpage to visitors.
- Security Groups: To control which network connections can reach the instance.
By the end, the website should be accessible through the public IP address of the EC2 instance.
2. Understanding the Architecture
Before starting, let's understand how the components communicate.
A user enters the website's public IP address in a browser. The request travels over the internet to the EC2 instance. Nginx receives the request and returns the webpage stored on the server.
The basic architecture is:
User Browser → Internet → EC2 Instance → Nginx → HTML Webpage
This example uses a single virtual server. It is a simple way to understand the fundamentals before moving on to more advanced deployment architectures.

3. Step 1: Launch an Amazon EC2 Instance
First, sign in to the AWS Management Console and open the Amazon EC2 service.
Follow these steps:
- Open the Instances section and select Launch instances.
- Give your instance a name, such as
MyFirstWebServer. - Select Amazon Linux 2023 as the Amazon Machine Image (AMI).
- Choose a small instance type suitable for a basic learning exercise.
- Create or select a key pair if you plan to connect using SSH.
- Configure the network and security group.
- Launch the instance.
Wait until the instance is running and its status checks have passed.
An EC2 instance is essentially a virtual computer in the AWS Cloud. You can choose its computing capacity, operating system, storage, and networking configuration according to your requirements.

4. Step 2: Configure the Security Group
Security is an important part of deploying any internet-facing application.
An EC2 security group acts as a virtual firewall that controls incoming and outgoing traffic.
For this project, configure these inbound rules:
| Type | Port | Source |
|---|---|---|
| SSH | 22 | My IP |
| HTTP | 80 | Anywhere IPv4, if the webpage should be publicly accessible |

Port 22 allows SSH connections for administration. Restrict it to your own IP address rather than exposing SSH to everyone.
Port 80 allows browsers to access the website using HTTP.
Important: These rules are for a basic learning example. For a production website, use HTTPS, stronger access controls, and an appropriate security configuration.
5. Step 3: Connect to the EC2 Instance
Once the instance is running, select it in the EC2 console and choose Connect.
You can use EC2 Instance Connect if your instance and account configuration support it, or connect through an SSH client using your private key.
For Amazon Linux, the default SSH username is generally
ec2-user.An SSH command follows this format:
1
ssh -i "my-key.pem" ec2-user@YOUR_PUBLIC_IPReplace
my-key.pem with the path to your private key and YOUR_PUBLIC_IP with the instance's actual public IP address.Keep your private key secure and never share it publicly.
After connecting, you can run commands on the cloud server just as you would on a Linux machine.
6. Step 4: Install and Start Nginx
Now we need a web server to deliver our webpage.
On the connected Amazon Linux 2023 instance, run:
1
2
3
sudo dnf update -y
sudo dnf install nginx -y
sudo systemctl enable --now nginxThese commands update available packages, install Nginx, and start the service while configuring it to start automatically when the instance boots.
To check whether Nginx is running, execute:
1
sudo systemctl status nginxIf the service is active, we can move on to creating our webpage.
7. Step 5: Create a Simple Webpage
We will create a basic HTML page and place it in Nginx's default web directory.
Run this command on the EC2 instance:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
sudo tee /usr/share/nginx/html/index.html > /dev/null <<'EOF'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My First AWS Website</title>
</head>
<body>
<h1>Hello from AWS EC2!</h1>
<p>My first webpage is running on a cloud server.</p>
</body>
</html>
EOFThis creates an HTML file named
index.html.Nginx will serve this file when a visitor requests the website's root page.
You can customize the HTML with your own text, headings, links, and styles.
8. Step 6: Open Your Website
Return to the EC2 console and copy your instance's public IPv4 address.
Open a browser and enter:
http://YOUR_PUBLIC_IPReplace the placeholder with the actual address of your instance.
If Nginx is running and the security group permits HTTP traffic, you should see your webpage.
Congratulations! You have learned the basic process of deploying a simple website on an AWS virtual server.
If the webpage does not load, check that the instance is running, Nginx is active, the public IP address is correct, and the security group allows inbound HTTP traffic on port 80.
9. Important Lessons From This Project
Even a small website introduces several important cloud computing concepts.
Virtualization: EC2 provides computing resources without requiring you to own a physical server.
Networking: Public IP addresses and security groups determine how users and administrators can reach the server.
Linux administration: Installing software and managing services are useful skills when working with cloud infrastructure.
Web hosting: Nginx receives HTTP requests and delivers the requested webpage.
Security: Access should be restricted to the ports and users that actually need it.
These concepts form a useful foundation for learning more advanced AWS services.
10. What Can We Learn Next?
After understanding this basic deployment, there are several ways to improve the project:
- Configure a domain name using Amazon Route 53.
- Add HTTPS using a suitable certificate and deployment architecture.
- Explore Amazon CloudWatch for monitoring and logs.
- Learn how IAM policies and roles control access to AWS resources.
- Explore Amazon S3 for static website hosting.
- Learn how automated deployment workflows can update an application.
Each step introduces new concepts and helps build a stronger understanding of cloud architecture.
11. Cost and Security Considerations
Before experimenting with AWS, remember that cloud resources can incur charges.
Check the current pricing and applicable Free Tier or other free-plan benefits before launching resources. Eligibility and usage limits depend on the account and service.
When you finish experimenting, stop or terminate resources that you no longer need, as appropriate. Remember that stopping an instance does not necessarily eliminate every associated charge, such as certain storage costs.
Also, never publish private keys, passwords, access tokens, or other credentials in an article or public repository.
Learning to manage costs and permissions is just as important as learning to deploy an application.
Conclusion
Deploying a simple website on Amazon EC2 is a practical way to understand how cloud computing works.
We explored how to launch a virtual server, configure a security group, connect to the instance, install Nginx, create an HTML webpage, and make it accessible through a public IP address.
Although this is only a basic example, it introduces concepts that are useful for building more advanced applications.
As I continue learning AWS, my goal is to move from understanding individual services to building complete projects and learning how different cloud components work together.
The best way to begin learning cloud computing is to start with a small project, understand each step, and gradually build on that knowledge.

References
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article