Skip to content

Instantly share code, notes, and snippets.

@adojos
Last active October 4, 2022 13:38
Show Gist options
  • Save adojos/c1cd8eff807e6b6dd22f4b344b349077 to your computer and use it in GitHub Desktop.
Save adojos/c1cd8eff807e6b6dd22f4b344b349077 to your computer and use it in GitHub Desktop.
XAMPP | Apache: Config for 'windows 'hosts' file' Implementing single-port and multi-virtualHosts [Part 4 of 4]

[Part 4 of 4] Apache Single-Port & Multi-Host Windows hosts file Config


In order to have a multi-port configuration for different virtual hosts (projects, websites) on Apache in XAMPP, you need to make changes to the following 3 Apache configuration files and 1 windows host file:

1. httpd.conf (\XAMPP\apache\conf)

2. httpd-ssl.conf (\XAMPP\apache\conf\extra)

3. httpd-vhosts.conf (\XAMPP\apache\conf\extra)

4. Windows 'hosts' file (C:\Windows\System32\drivers\etc) 👇 This file 👇


👉 Target Scenario:

1) Implement 4 named and independent Virtual Hosts
2) Implement 1 HTTP port to be used by all above Virtual Hosts (Port:8081)
3) Implement 1 HTTPS port to be used by all above Virtual Hosts (Port:8082)

Checkout the following gist links for complete changes to above configuration files each:

1. [Part 1 of 4] Apache Single-Port & Multi-Host 'httpd.conf' Config

2. [Part 2 of 4] Apache Single-Port & Multi-Host 'httpd-ssl.conf' Config

3. [Part 3 of 4] Apache Single-Port & Multi-Host 'httpd-vhosts.conf'

4. [Part 4 of 4] Apache Single-Port & Multi-Host Windows hosts file Config


Windows Host File (C:\Windows\System32\drivers\etc)

If you are using the windows machine as the host for your XAMPP then you need to update the 'windows host file' with the name of your virtual hosts. You can name your virtual hosts anythng you want, here is copy of my production file for referring syntax only.


👉 NOTE: Do not copy the whole file 'as-is', because it has been lifted from my production environment and may have hard-coded directory paths. I recommend only to refer the quoted key changes/modifications


127.0.0.1 localhost
127.0.0.1 www.website1.com
127.0.0.1 website2
127.0.0.1 automationdojos-demo
127.0.0.1 automationdojos-dev
127.0.0.1 automationdojos-prod
127.0.0.1 wordpress-vanilla
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment