22BSA10026
TANISHA GUPTA
How to Launch an EC2 Instance and Set
Up a Web Server Using HTTPD
Here’s a structured step-by-step AWS practical guide based on your Table of Contents,
perfect for beginners trying to understand EC2 and host a custom web page using HTTPD
(Apache):
📝 Table of Contents
1. What is EC2?
2. What is HTTPD?
3. Step 1: How to Launch Your EC2 Instance
4. Step 2: How to Connect to Your EC2 Instance
5. Step 3: How to Install and Start HTTPD (Apache Web Server)
6. Step 4: How to Host Your Custom Web Page
🔹 What is EC2?
Amazon EC2 (Elastic Compute Cloud) is a web service that provides secure, resizable
compute capacity in the cloud. It allows users to run virtual machines (instances) with various
configurations of CPU, memory, storage, and networking.
🔹 What is HTTPD?
HTTPD refers to the Apache HTTP Server, one of the most widely used web servers. It's
open-source software used to serve web content over the Internet.
✅ Step 1: How to Launch Your EC2 Instance
1. Log in to your AWS Console.
2. Navigate to EC2 from the Services menu.
3. Click on Launch Instance.
4. Provide:
○ Name: e.g., MyWebServer
○ AMI: Choose Amazon Linux 2 (Free Tier eligible)
○ Instance type: t2.micro (Free Tier)
○ Key pair: Create a new one or use an existing one (.pem file)
○ Network settings:
■ Allow SSH (port 22)
■ Allow HTTP (port 80)
5. Click Launch Instance.
6. Wait for instance state to show "running" and note the Public IPv4 address.
✅ Step 2: How to Connect to Your EC2 Instance
1. Open Terminal (Linux/macOS) or Git Bash (Windows).
Run the following command:
ssh -i "your-key.pem" ec2-user@<your-public-ip>
2. Replace:
○ your-key.pem with your private key file name
○ <your-public-ip> with the actual IP of your EC2 instance
3. If prompted, type yes to continue connecting.
✅ Step 3: How to Install and Start HTTPD (Apache Web
Server)
Once connected to your instance:
Update packages:
sudo yum update -y
1.
Install HTTPD:
sudo yum install httpd -y
2.
Start HTTPD:
sudo systemctl start httpd
3.
Enable HTTPD to start on boot:
sudo systemctl enable httpd
4.
Check status (optional):
sudo systemctl status httpd
5.
✅ Step 4: How to Host Your Custom Web Page
Create/edit the default HTML file:
sudo nano /var/www/html/index.html
1.
Add your custom content. Example:
<html>
<head><title>Welcome</title></head>
<body>
<h1>Hello from EC2!</h1>
<p>This is my custom web page hosted on Apache.</p>
</body>
</html>
2.
3. Save and exit:
○ Press Ctrl + X, then Y, then Enter
Visit your public IP in a browser:
http://<your-public-ip>
4. You should see your custom web page!
Let me know if you want a downloadable PDF of this guide or a hands-on lab worksheet to go
along with it!