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.
stapp02)jump_host)5004 (Custom Port)/home/thor/official and /home/thor/apps on Jump Hosthttp://localhost:5004/official/ (Mapped to /var/www/html/official)http://localhost:5004/apps/ (Mapped to /var/www/html/apps)å
Access the App Server 2 (stapp02) from the Jump Host via SSH:
ssh steve@stapp02
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
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
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
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>
Restart the Apache service to apply the configuration modifications:
sudo systemctl restart httpd
Verify the service status is active:
sudo systemctl status httpd
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.