0% found this document useful (0 votes)
10 views3 pages

Port Based Apache Configuration

Uploaded by

arpmovieclips
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

Port Based Apache Configuration

Uploaded by

arpmovieclips
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Port Based Apache Configuration

Step 1 – Configure Apache to Listen on Port 8080 and 8081


First, you must configure the Apache webserver to listen on ports 8080 and 8081.
You can do it by editing the file /etc/apache2/ports.conf:

sudo nano /etc/apache2/ports.conf

Add the following lines precisely below the line Listen 80:

Listen 8081
Listen 8080

Step 2 – Create a Directory Structure


First, create a document root directory for both websites:

sudo mkdir /var/www/html/8080


sudo mkdir /var/www/html/8081

Next, create an index.html page for both websites.

First, create an index.html page for the website hosted on port 8080:

sudo nano /var/www/html/8080/index.html

Add the following lines;

<html>
<title>GU Site</title>
<h1> Success! GU Website is running on Port 8080</h1>
</html>

Save and close the file.

Next, create an index.html page for the website hosted on port 8081:

sudo nano /var/www/html/8081/index.html

Add the following lines:

<html>
<title>GU Site</title>
<h1> Success! GU Website is running on Port 8081</h1>
</html>
Save and close the file.
Next, change the ownership of both websites to www-data:

sudo chown -R www-data:www-data /var/www/html/8080


sudo chown -R www-data:www-data /var/www/html/8081

Step 3 – Create a Virtual Host Configuration File


Next, you must create an Apache virtual host configuration file to serve both
websites.

First, create an Apache virtual host configuration file for the website hosted on port
8080:

sudo nano /etc/apache2/sites-available/8080.conf

Add the following lines;

<Directory /var/www/html/8080>
Require all granted
AllowOverride None
</Directory>

<VirtualHost *:8080>
DocumentRoot /var/www/html/8080
ServerAdmin [email protected]
ErrorLog "/var/log/apache2/site8080_error_log"
CustomLog "/var/log/apache2/site8080_access_log" combined
</VirtualHost>

Save and close the file.

Next, create an Apache virtual host configuration file for the website hosted on port
8081:

sudo nano /etc/apache2/sites-available/8081.conf

Add the following lines;

<Directory /var/www/html/8081>
Require all granted
AllowOverride None
</Directory>

<VirtualHost *:8081>
DocumentRoot /var/www/html/8081
ServerAdmin [email protected]
ErrorLog "/var/log/apache2/site8081_error_log"
CustomLog "/var/log/apache2/site8081_access_log" combined
</VirtualHost>

Save and close the file. Then, enable the virtual host with the following command:

sudo a2ensite 8080


sudo a2ensite 8081

Finally, restart the Apache webserver to apply the changes:

sudo systemctl restart apache2

You might also like