dev-ops-challenges

Apache Custom Port and Virtual Directories Configuration Guide

Technical Overview

Apache HTTP Server (httpd) is a highly modular, open-source web server capable of hosting multiple distinct websites, applications, and directories. In enterprise DevOps environments, web servers are often configured to host multiple static assets or micro-frontends on custom ports to accommodate network routing rules, internal staging processes, or Dockerized reverse-proxy configurations.

This guide details the step-by-step procedure to configure Apache on App Server 2 (stapp02) to serve multiple static websites on a custom port (5004), referencing content from backups transferred from the Jump Host.


Infrastructure & Configuration Requirements


å

Step-by-Step Implementation

Step 1: Connect to App Server 2

Access the App Server 2 (stapp02) from the Jump Host via SSH:

ssh steve@stapp02

Step 2: Install Apache HTTP Server

Update repository packages and install the Apache httpd package and its dependencies:

# Install the httpd package
sudo yum install -y httpd

# Start the Apache service and enable it to persist across reboots
sudo systemctl enable httpd
sudo systemctl start httpd

Step 3: Configure Apache to Listen on Port 5004

By default, Apache listens on port 80. Edit the main configuration file to modify the listening port:

sudo vi /etc/httpd/conf/httpd.conf

Locate the Listen directive:

Listen 80

Update it to:

Listen 5004

Step 4: Transfer and Deploy Website Backups

First, exit the SSH session on App Server 2 to return to the Jump Host:

exit

On the Jump Host, transfer the static website backups to the target app server using scp:

scp -r /home/thor/official steve@stapp02:/tmp/
scp -r /home/thor/apps steve@stapp02:/tmp/

Now, log back into App Server 2:

ssh steve@stapp02

Move the transferred directories into Apache’s document root /var/www/html/:

sudo mv /tmp/official /var/www/html/
sudo mv /tmp/apps /var/www/html/

Ensure directory permissions allow Apache to read the files:

sudo chmod -R 755 /var/www/html/official
sudo chmod -R 755 /var/www/html/apps

Step 5: Configure Apache VirtualHost

To ensure Apache correctly serves request routes over port 5004, append a VirtualHost configuration to /etc/httpd/conf/httpd.conf:

sudo vi /etc/httpd/conf/httpd.conf

Append the following block at the bottom of the file:

<VirtualHost *:5004>
    DocumentRoot /var/www/html
    <Directory "/var/www/html">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Step 6: Restart and Verify the Service

Restart the Apache service to apply the configuration modifications:

sudo systemctl restart httpd

Verify the service status is active:

sudo systemctl status httpd

Post-Deployment Verification

Verify that the websites are reachable and serving content properly on the custom port using curl:

# Test the official website path
curl http://localhost:5004/official/

# Test the apps website path
curl http://localhost:5004/apps/

Expected outputs should return the HTML index page content for each respective site backup.