Apache Port-Based Virtual Hosting (Step-by-Step Guide)
2 min readFeb 22, 2026
Port-based virtual hosting allows you to serve multiple websites using different port numbers on the same server IP.
Step 1: Install Apache
Update your system and install Apache:
sudo apt install apache2Check the status:
sudo systemctl status apache2Enable Apache to start on boot:
sudo systemctl enable apache2Step 2: Configure Apache Ports
Edit the ports configuration file:
sudo vim /etc/apache2/ports.confAdd the following lines:
Listen 8080
Listen 8081
Save and exit: :wq!Step 3: Create Website Directories
Create directories for both sites:
sudo mkdir /var/www/html/8080
sudo mkdir /var/www/html/8081Step 4: Create Index Files
0 Comments