DEV Community

Augustine Okwaraebuzie
Augustine Okwaraebuzie

Posted on

STEPS ON HOW TO LAUNCH AN APACHE WEB SERVER USING EC2 INSTANCE

Introduction

The Amazon Elastic Compute Cloud (EC2) offers the broadest and deepest compute platform, Its a powerful service that allows users to run virtual machines in the cloud. Launching a web server on EC2 is a fundamental task for developers, DevOps engineers, and anyone working with cloud infrastructure

As part of this process, I will also show detailed screenshots annotated using Screenpresso at each step to make the process clear and easy to follow.

This article provides a step by step guide on how to launch an EC2 web server using AWS.

Requirements
To begin, make sure you have the following:

  • An active AWS account

  • An Installed text editor like (Gitbash)

  • SSH client (e.g., Terminal on macOS/Linux, PuTTY on Windows)

Step 1: Log in to the AWS Management Console

First you Visit https://aws.amazon.com/

Click on “Sign In to the Console.”

Enter your login credentials and navigate to the EC2 Dashboard.

Its important to note that the AWS Console is the web interface that
allows you to manage all AWS services

Image description

Image description

Step 2: Launch a New EC2 Instance

From the EC2 Dashboard, click on “Launch Instance.”

Image description

Enter a name for your instance (e.g., MyWebServer).

Image description

Choose an Amazon Machine Image (AMI):

Select Amazon Linux 2023, Ubuntu Server 22.04, or any preferred Linux distribution.

Image description

Choose an Instance Type:

Select t2.micro (Free tier eligible).

Image description

Create or choose a key pair for SSH access:

If new, click “Create new key pair” and download the .pem file.
Choose RSA and select .pem format (for Git Bash).

Download and securely save the key file (example: MyKeyPairin.pem).This file is the only way to SSH into your instance. Don’t lose it!

Image description

Image description

Configure Network Settings:

Create or use an existing security group.

Allow SSH (port 22) and HTTP (port 80) in the inbound rules.

Leave the rest of the settings at default and click “Launch Instance.”

Image description

Image description

Step 3: Connect to Your EC2 Instance
After the instance is running, click on “Connect” in the EC2 dashboard.

Image description

Step 4: Open Git Bash

Git Bash allows Windows users to use Linux commands and connect via SSH.

** Navigate to Your Key Pair File**

cd /c/Users/YourUsername/Downloads

Replace YourUsername with your actual Windows username.

Set Correct File Permissions

chmod 400 MyKeyPairin.pem

This step is required to ensure your SSH key is secure. Without this, Git Bash will not allow the connection.

Connect via SSH

ssh -i MyKeyPairin.pem ec2-user@

Replace with the IP address of your EC2 instance.

What to expect:You will see a security prompt the first time. Type yes to continue. You should now be inside your EC2 server terminal.
Use the provided SSH command in your terminal

Image description

Image description

Image description

Step 4: Update system and Install a Web Server (Apache or Nginx)
Update System Packages

sudo yum update -y

This ensures your system is up to date.

Install NGINX Web Server

sudo amazon-linux-extras install nginx1 -y

This installs NGINX from the Amazon Linux repositories.

Start the NGINX Service

sudo systemctl start nginx

Starts the web server so it can serve web pages.

Enable NGINX on Boot

sudo systemctl enable nginx

This ensures NGINX starts automatically when the server restarts.

Image description

Test Apache HTTP Web Server in Browser

Open your browser and visit:

http://

You should see the default Apache HTTP server has been installed and working properly.

Why this is significant because it confirms that your NGINX web server is correctly installed and reachable.

Image description

Conclusion

In this article, You've successfully launched an EC2 web server. From here, you can upload your website files, configure domains, install SSL, or build a dynamic application. Amazon EC2 is a versatile and scalable platform that provides the foundation for many cloud-hosted applications.

Top comments (0)