Welcome to the AWS EC2 Tutorial! This guide will take you through everything you need to know about Amazon Elastic Compute Cloud (EC2)βfrom launching instances to hosting your first webpage!
π― What is AWS EC2?
Amazon EC2 is a web service that provides resizable compute capacity in the cloud. It enables businesses to deploy applications quickly without hardware investments.
π Table of Contents
- π Why Learn EC2?
- π Getting Started
- π¦ EC2 Instance Types
- βοΈ Launching an EC2 Instance
- π Hosting a Simple Webpage
- π Security Best Practices
- π Monitoring and Scaling
- π Conclusion
π Why Learn EC2?
- π Cloud Computing Mastery: EC2 is the backbone of AWS services.
- πΌ Career Growth: EC2 knowledge is crucial for DevOps, cloud engineers, and developers.
- π Real-World Applications: Use EC2 to host websites, deploy applications, or run data pipelines.
π Getting Started
Prerequisites
Before you begin, ensure you have:
- β An AWS account (free-tier eligible).
- β Basic knowledge of cloud computing.
π¦ EC2 Instance Types
AWS EC2 offers various instance types tailored for different workloads:
Type | Use Case | Examples |
---|---|---|
General | Balanced performance |
t2.micro , t3.small
|
Compute | High-performance computing |
c5.large , c6i.xlarge
|
Memory | Memory-intensive apps |
r5.large , r6g.xlarge
|
Storage | Data-heavy workloads |
i3.large , i4i.xlarge
|
GPU | Machine learning, gaming |
g5.large , p3.2xlarge
|
βοΈ Launching an EC2 Instance
Follow these steps to launch your first EC2 instance:
-
Login to AWS Console π₯οΈ
- Navigate to EC2 under the "Compute" section.
-
Click "Launch Instance" π
- Provide a name for your instance.
- Select an AMI (Amazon Machine Image) like Ubuntu, Amazon Linux, or Windows Server.
-
Choose an Instance Type π±οΈ
- For beginners, choose
t2.micro
(free-tier eligible).
- For beginners, choose
-
Configure Security Groups π
- Add rules to allow inbound traffic for HTTP (port 80) and SSH (port 22).
-
Key Pair ποΈ
- Create or select an existing key pair for secure access.
-
Launch Your Instance π
- Click Launch Instance and wait for it to initialize.
π Hosting a Simple Webpage
Hereβs how you can host a basic index.html
file on your EC2 instance.
Step 1: Install a Web Server
Log into your EC2 instance via SSH and run the following commands to install a web server:
# Update the package manager
sudo apt update
# Install Apache2
sudo apt install apache2 -y
# Start Apache2 service
sudo systemctl start apache2
# Enable Apache2 to start on boot
sudo systemctl enable apache2
Step 2: Create Your Webpage
Navigate to the default web server directory and create an index.html
file:
# Navigate to the default directory
cd /var/www/html
# Create or edit the index.html file
sudo nano index.html
Add the following content to your index.html
file:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to My Webpage</title>
</head>
<body>
<h1>π Welcome to My First AWS EC2 Hosted Webpage!</h1>
<p>This is a simple webpage hosted on an EC2 instance.</p>
</body>
</html>
Save and exit (Ctrl+O
, Enter
, Ctrl+X
).
Step 3: Open Your Webpage
- In your browser, navigate to:
http://<Public_IP_of_EC2_Instance>
You should see your index.html
webpage live! π
π Security Best Practices
- Use Security Groups: Restrict inbound traffic to only required ports.
-
Key Management: Keep your
.pem
file secure. - IAM Roles: Assign least privilege roles to your instances.
π Conclusion
With this guide, youβve:
- Launched your first EC2 instance.
- Installed a web server.
- Hosted your first
index.html
webpage.
Continue exploring AWS to enhance your cloud computing skills!
Need Help? Reach out on AWS Forums or join the AWS Community.
Happy Hosting! π
By Rajeev Kumar
Top comments (0)