DEV Community

Rolland Francis
Rolland Francis

Posted on

๐Ÿ› ๏ธ Deploying an Apache Web Server on AWS EC2: A Step-by-Step Guide

INTRODUCTION

This guide outlines the process of provisioning an EC2 instance and configuring it to host a basic Apache web server.

1. Launch an EC2 Instance
Sign in to the AWS Management Console.

Navigate to EC2 Dashboard and select Launch Instance.

Configure the instance:

Name: Give your instance a meaningful name (e.g., Apache-Web-Server).

AMI: Choose Amazon Linux 2 AMI (HVM), SSD Volume Type (or Ubuntu, if preferred).

Instance Type: Select t2.micro (eligible for Free Tier).

Key Pair: Create or choose an existing key pair to access the instance via SSH.

Network Settings:

Allow SSH (port 22) and HTTP (port 80).

Click Launch Instance.

Step 1: Connect to the EC2 Instance
On the EC2 Dashboard, select your instance and click Connect.

Part 2: Connecting to the EC2 Instance Using SSH with Git Bash
Requirements:

The .pem key file.
The Public IPv4 address of the EC2 instance.

Step 1: Open Git Bash

Step 2: Navigate to the Key File Directory
cd Downloads

Image description

Step 3: List Files to Verify the Key File
ls

Image description

Step 4: Secure the Key File
chmod 400 my-ec2-key.pem

Image description

Step 5: Connect to the EC2 Instance
ssh -i "my-ec2-key.pem" ec2-user@3.120.150.55

Image description

When prompted, type yes to continue connecting.

Part 3: Installing and Starting the Apache Web Server
Step 1: Update the Package List
sudo yum update -y

Image description

Step 2: Install Apache
sudo yum install -y httpd

Image description

Step 3: Start Apache
sudo systemctl start httpd

Image description

Step 4: Enable Apache to Start on Boot

Image description

Conclusion
You have successfully deployed an Apache web server on an AWS EC2 instance. This configuration provides a basic public-facing web server, ready for static or dynamic web content.

Top comments (0)