Using addon domains with WAMPserver

From Cheeky Factor

Status: Archived
Publication date: 2018-09-11
Last edited by: Garyf
Last updated: 2024 - 09 - 1

The problem

Don’t judge here, it is not my choice here, for one of my servers I am forced to use Windows 2012 R2, I have WAMPserver installed on this server.

So, it came to a point where I needed to have different domain names pointing to different directories on the server. So I have a main domain, say for example domainname.com, but I need to have domaintwo.com on the same server. With what I am about to show you, you can have as many domains as you want, if you are working locally you can also have say local1.domain and local2.domain.

Right so how can this be done? Well, first of all I will show you how to do the local domains.

The resolution

Please note: cheekyfactor.com or the owners of this site cannot be held responsible if things go wrong. You perform these tasks at your own risk.


Device: Server
Operating system: Windows Server 2012
Software: WAMP

Guidance for Server, Windows Server 2012, WAMP

Create a new directory for the second site in the www root:

Add on domain for a WAMP server

I’ll keep this as Newfolder.

Click on the WAMP icon in your task bar, hover over APACHE and click on the httpd.conf:

Locate httpd.conf file in WAMP

You’ll get:

The httpd.conf file contents

Find:

LoadModule vhost_alias_module modules/mod_vhost_alias.so

Uncomment it (normally starts with a #. If it’s already uncommented leave it.

Find:

Virtual Hosts

Uncomment the line

Include conf/extra/httpd-vhosts.conf

Again, this may have a # in front of it, remove it. If it doesn’t leave it. Save the file and close it.

Go back to the WAMP symbol, go back to APACHE and click on httpd-vhosts.conf

httpd-vhosts.conf

Add the following code below the </VirtualHost>:

<VirtualHost *:80>

DocumentRoot “${INSTALL_DIR}/www/Newfolder”

ServerName newfolder.local

</VirtualHost>

httpd-vhosts.conf edited

Repeat for as many as you need, changing Newfolder and newfolder1.local to what you require.

There are other options that we won’t go to here. Save the file.

Now we need to point Windows to recognise those domains.

Open the directory:

C:\Windows\System32\drivers\etc\

Open the hosts file:

The hosts file

Save the file.

Go back to the WAMP icon and restart all services:

WAMP Options to restart WAMP services

Make sure it works. I have stuck a basic HTML file into the directory for newfolder1.local

Sample add on domain

To make it so you can point your URL external to local to the server you will need to make a few changes.

To make it so you can point your URL on the net, or WAMPserver is installed somewhere else other than on the C drive add the following to the httpd-vhosts.conf:

<VirtualHost *:80>

DocumentRoot “D:\wamp64\www\YOURFOLDER”

ServerName YOURDOMAIN.COM

<Directory “D:\wamp64\www\YOURFOLDER”>

AllowOverride All

Require all granted

</Directory>

</VirtualHost>

In the hosts page use the following code instead:

111.222.333.444 YOURDOMAIN.COM

Replace 111.222.333.444 with your IP address.

Job done!