DEV Community

Joseph Ibeh
Joseph Ibeh

Posted on

Building a Scalable Web Server on AWS: A Hands-On Guide to Linux, Apache, and SSL Configuration

Introduction

Building a web server from scratch is an essential skill for any cloud or DevOps engineer. This project walks you through provisioning a Linux server, installing Apache, deploying a custom HTML landing page, and securing the server with SSL encryption. Whether you're a beginner or looking to solidify your skills, this guide provides practical steps to help you deploy a scalable and secure web server.

Objective

The main goals of this project are:

  1. Provision a Linux server on AWS.
  2. Install and configure Apache as a web server.
  3. Create and deploy a custom HTML landing page.
  4. Configure networking to allow HTTP (port 80) and optionally HTTPS (port 443) traffic.
  5. Secure the server with SSL encryption using Certbot.

Tools and Technologies Used

  • Cloud Platform: AWS (Amazon Web Services)
  • Linux Distribution: Ubuntu
  • Web Server: Apache
  • SSH: For server connection and management
  • HTML: To design the landing page
  • Certbot: To manage SSL certificates for HTTPS

Steps to Build the Project

1. Provisioning the Server on AWS

Step 1: Sign In to AWS

Step 2: Launch a New Instance

  1. Navigate to EC2 and click "Launch Instance."
  2. Choose an Ubuntu Linux AMI (e.g., Ubuntu 22.04 LTS).
  3. Configure instance settings:
    • Assign a public IP for accessibility.
    • Choose an instance type (e.g., t2.micro for free tier users).

aws log in

launch instance

server name

AMI

Step 3: Configure Key Pair

  • Create a new key pair and download the private key file (.pem).

Key pair

Step 4: Configure Security Group

  • Allow the following inbound rules:
    • HTTP (port 80)
    • HTTPS (port 443)
    • SSH (port 22)

SG

Step 5: Launch the Instance

  • Click "Launch Instance" and wait for it to start running.

launch instance

Instance running

2. Connecting to the Server

  1. Open a terminal or Git Bash.
  2. Use the private key to SSH into the server:
   ssh -i path_to_private_key.pem ubuntu@public_ip_address  
Enter fullscreen mode Exit fullscreen mode

SSHing

3. Setting Up the Web Server

-Switch to root user sudo -i

root user

Step 1: Update the System

sudo apt update && sudo apt upgrade -y  
Enter fullscreen mode Exit fullscreen mode

Step 2: Install Apache

sudo apt install apache2 -y  
sudo systemctl start apache2  
sudo systemctl enable apache2  
Enter fullscreen mode Exit fullscreen mode

apache

Step 3: Verify Apache Installation

  • Open a browser and navigate to the server's public IP address. You should see the Apache default page.

4. Deploying a Custom HTML Landing Page

Step 1: Create the HTML File

  • Open the Apache default directory:
  sudo vim /var/www/html/index.html  
Enter fullscreen mode Exit fullscreen mode
  • Add your custom HTML content:

html content

html content contd

Step 2: Save and Exit

Step 3: Test the Landing Page

  • Open a browser and visit the server’s public IP address.

landing page 1

landing page 2 ns

5. Configuring SSL for HTTPS

Prerequisites:

  • Purchase a domain name (e.g., yourname.com).
  • Update your domain's DNS settings to point to your server's public IP address.

Step 1: Install Certbot

sudo apt install certbot python3-certbot-apache -y  
Enter fullscreen mode Exit fullscreen mode

Step 2: Obtain an SSL Certificate

sudo certbot --apache -d yourname.com -d www.yourname.com  
Enter fullscreen mode Exit fullscreen mode

certbot

Step 3: Verify HTTPS

  • Open a browser and navigate to https://yourname.com.

landing page s

landing page 2 s

Conclusion

This project highlights the essential steps to provision a server, deploy a web server, and secure it with HTTPS. By following this guide, you’ll gain hands-on experience with server management, web hosting, and cloud technologies.

Feel free to customize this project and share your version with the tech community. Let’s keep building and learning together!

Top comments (0)