Many of us run a local version of the WAMP stack either on a laptop or development desktop, I run a version of Moodle on mine so I can test (and break) things to my hearts content without disrupting the main production server.
Recently a collegue of mine required some assistance with setting up Apache Virtual Hosts on a production server. It had been a while since I had done this so I decided to practise on my laptop as not to break the server. It was then I realised I would have to set up domain names on my laptop so I could check the virtual hosts actually work from sub domains. This got me thinking, “Why would anyone need other domains on a localhost pc?” After all, I simply type http://localhost/moodle or http://localhost/moodle2 etc.. to test my dummy sites. But then I liked the idea of typing http://moodle or http://wordpress to access my test sites! So hence this tutorial was born.
Edit the following file
And include the extra hosts you require:
Now edit your apache config file and uncomment the line
Now create a new folder anywhere on your system, this is where your new virtual host web pages will reside
Edit the file
Paste the following below and edit to match the paths to your created folders and substitute server name with the names of your hosts you created.
Now restart apache and test your host names by typing them in your browser. In the example above if I type http://wordpress then my browser points to a new folder on my C drive called vhosts. If I type http://localhost it defaults to my WAMP installation.Have fun!