DEV Community

cs vishnukumar
cs vishnukumar

Posted on

How to Deploy a Website on AWS EC2 – Step-by-Step Guide?

Deploying a website on the cloud is a must-have skill for anyone entering the IT industry. Amazon Web Services (AWS) provides powerful and scalable infrastructure, and one of its core services is Amazon EC2. In this guide, you’ll learn how to deploy a website on AWS EC2 step by step in a simple and beginner-friendly way.

☁️ What is AWS EC2?

Amazon EC2 (Elastic Compute Cloud) is a web service that allows users to launch virtual servers, known as instances, in the cloud. These instances can be used to host websites, applications, and databases. It gives you full control over the server, just like a physical machine, but without the need for hardware.

🛠️ Prerequisites

Before starting the deployment, ensure you have the following:

An active AWS account
Basic knowledge of Linux commands
A simple website (HTML/CSS files)
An SSH client such as Terminal or PuTTY
⚙️ Step-by-Step Deployment
🔹 Step 1: Launch an EC2 Instance

Log in to your AWS Management Console and navigate to the EC2 dashboard. Click on “Launch Instance.” Choose an Amazon Linux AMI, which is beginner-friendly and free-tier eligible. Select the instance type as t2.micro.

Next, configure the security group by allowing:

SSH (Port 22) – to access your server
HTTP (Port 80) – to display your website

Finally, review and launch the instance. Download the key pair file (.pem), which is required to connect to your server.

🔹 Step 2: Connect to Your Instance

Open your terminal and connect using the following command:

ssh -i your-key.pem ec2-user@your-public-ip

Replace “your-public-ip” with your instance’s public IP address.

🔹 Step 3: Install Apache Web Server

Once connected, install a web server to host your website. Run the following commands:

sudo yum update -y
sudo yum install httpd -y
sudo systemctl start httpd
sudo systemctl enable httpd

This installs and starts the Apache web server on your EC2 instance.

🔹 Step 4: Upload Website Files

Navigate to the web directory:

cd /var/www/html

Create or edit your HTML file:

sudo nano index.html

Paste your website code and save the file. This file will act as your homepage.

🔹 Step 5: Access Your Website

Open a browser and enter your EC2 public IP address:

👉 http://your-public-ip

If everything is configured correctly, your website will be live and accessible from anywhere.

⚠️ Common Issues and Fixes
Website not loading: Ensure Port 80 is enabled in the security group
Permission issues: Use sudo for administrative commands
Apache not running: Restart using sudo systemctl restart httpd
💼 Career Benefits

Learning how to deploy websites on AWS is a foundational skill for roles like Cloud Engineer, DevOps Engineer, and System Administrator. With the increasing adoption of cloud technologies in India, AWS skills are highly in demand, especially among freshers aiming to enter the IT field.

🎯 Conclusion

Deploying a website on AWS EC2 is a straightforward process once you understand the steps. It not only helps you build real-time project experience but also strengthens your cloud computing knowledge. Start practicing today and take your first step toward a successful cloud care

Top comments (0)