DEV Community

loading...

Adding virtual hosts in WAMP

Matthew Dailey
Software developer currently working in Angular, Bootstrap, and Angular Material. Branching out into devops.
・2 min read

The ability to have multiple domains running on a local server can be accomplished with virtual hosts. Setting up a virtual host in the past was tedious and time-consuming. The process involved updating multiple files that were hard to find. One of the reasons why MAMP Pro has become so popular is it automates the task of adding virtual hosts. Naturally you have to buy a license. Now WAMP makes it easy to add virtual hosts and its free. This feature is barely mentioned on WAMP's website. Googling how to add a virtual host in WAMP turns up outdated instructions. I thought I share these instructions for those who weren't aware WAMP can add a virtual host in a couple of steps.

Start WAMP and left-click the green WAMP desktop icon. If the icon is red then WAMP is not running correctly and you will need to troubleshoot the issue before continuing.
Click on Localhost. A new browser tab should open. The heading at the top of the page will say 'Server Configuration'. Scroll down to the bottom of the page and look for the subheading 'Tools'. See the screenshots below.
Click on 'Add a virtual host'. On the next page you need to fill out two fields. First type in the name of the virtual host you want to add. Whatever you type in will serve as the URL. For example if you type in 'newwebsite' as the name then the new domain's URL will be: http://newwebsite
In the second field put in the location where the website files reside on your computer. It has to be the complete file path. The files can be anywhere on your computer; they don't necessarily need to be inside the wamp folder. For myself I have one of my virtual hosts pointed to my git repository.
The third field you can leave blank. Click on the 'Start the creation of the VirtualHost' button. After a few minutes you will see the newly created virtual host listed near the top of the page.

There is no limit to the number of virtual hosts that can be added. To add another virtual host, just go back to the 'Add a virtual host' page and fill out the first two fields. To access the virtual hosts, left-click on the WAMP desktop icon, hover over 'My VirtualHosts', then choose which one to load.

Discussion (0)

Forem Open with the Forem app