My First EC2 Project
Hosting a Website on AWS as a Beginner Cloud computing has always fascinated me, but I never took the leap—until now.
Recently, I decided to dive into Amazon Web Services (AWS) and try hosting my first live website using EC2 (Elastic Compute Cloud). In this post, I’ll share how I did it, what I learned, and tips for anyone starting their AWS journey.
Amazon Web Services (AWS) is one of the most popular cloud platforms in the world. It offers reliable, scalable, and inexpensive computing services — and with AWS EC2, you can host your own website like a pro.
In this article, I’ll Walk you step-by-step through hosting a website on AWS, from setting up your account to accessing your site live on the internet.
What You’ll Learn
By the end of this tutorial, you’ll know how to:
- Create and configure an AWS EC2 instance
- Install a web server (Apache or Nginx)
- Upload and serve your website files
- Secure and manage your instance
** Steps I Followed**
1️⃣ Creating an AWS Account
I started by signing up for an AWS Free Tier account. This gave me enough credits to run my instance without worrying about costs.
https://aws.amazon.com/console
- Go to AWS Free Tier and click Create a Free Account.
- Follow the signup process (you’ll need a valid email and payment method).
- Once done, log into the AWS Management Console.
Step-by-Step – Launching a Linux EC2 Instance
1.Log in to your AWS Management Console.
2.In the search bar at the top, type EC2.
3.Click on EC2 to go to the EC2 dashboard.
Step 2: Launch a New EC2 Instance
- Click on the Launch Instance button.
- Name your instance: You can name it something like student-webserver.
- Choose an AMI (Amazon Machine Image):
a. Select Amazon Linux 2023 or Amazon Linux 2. These are free and beginner-friendly.
- Choose an Instance Type: a. Select t2.micro. This is eligible for the AWS free tier.
Step 3: Create a Key Pair (Very Important)
This key pair will help you securely connect to your EC2 instance.
- Under Key pair (login), click Create new key pair.
- Key pair name: Type my-ec2-key
- Key pair type: RSA
- Private key file format: Select .pem
- Click Create key pair
- Your browser will automatically download a file named my-ec2-key.pem. Save it in your Downloads folder. Important: Never lose this file. You cannot connect to your instance without it.
Step 4: Configure Security Group (Firewall Settings)
A security group acts like a firewall that controls who can access your instance.
- Create a new security group.
- Add these inbound rules:
Type Port Source Purpose
SSH 22 0.0.0.0/0 To connect to your server
HTTP 80 0.0.0.0/0 To view your website in browser
Step 5: Configure Storage
• Leave the default 8 GB SSD storage.
• This is enough for our basic project.
Step 6: Launch the Instance
• Click Launch Instance
• Wait for the instance to enter the Running state (this takes a few seconds)
Part 3: Connect to EC2 Using SSH via Git Bash
To manage your server, you’ll need to log in to it from your computer using SSH.
What You Need:
• The .pem key file you downloaded earlier
• Your EC2 Public IPv4 address
o Go to EC2 > Instances
o Look under the Public IPv4 address column
Steps:
- Install Git Bash (if you don’t already have it): https://git-scm.com/downloads
Open Git Bash on your computer.
Navigate to your Downloads folder (where your .pem file is located):
bash
CopyEdit
cd Downloads
Make the key file secure (this is required):
bash
CopyEdit
chmod 400 ~/Downloads/my-ec2-key.pemConnect to your EC2 instance using SSH:
bash
CopyEdit
ssh -i ~/Downloads/my-ec2-keypair.pem ec2-user@
Replace with your actual IP address (example: 18.120.23.45).
If prompted with a yes/no question, type yes and press Enter.
Part 4: Install Apache Web Server on EC2
Now that you're inside your Linux EC2 instance, follow these steps to install and start the Apache web server.
- Update all packages: bash CopyEdit sudo yum update -y
- Install Apache:
sudo yum install -y httpd
- Start Apache: sudo systemctl start httpd
- Enable Apache to start automatically on reboot:
sudo systemctl enable httpd
- View Your Server in a Browser: • Open your browser • Visit: http:// • You should see the Apache test page
Part 5: Create Your Own Web Page
Let’s change the default Apache test page to your own custom message.
-
Create a simple HTML page:
bash
CopyEdit
echo "Hello from EC2!
" | sudo tee /var/www/html/index.html Check your browser:
• Refresh http://
• You should now see "Hello from EC2!" displayed
Hosting a website on AWS EC2 can seem intimidating at first, but once you go through it step-by-step, it’s a powerful skill to have.
Top comments (2)
Nice 👏
thank you