Wamp ServerBeing able to develop on my local machine with urls like htto://testsite/index.php has been a godsend. Mostly because I am able to take full advantage of the document root. If I were to develop on something like http://localhost/testsite/index.php I would be extremely limited and forced to used relative urls. In this article I've listed the steps in order to enable this functionality in a wamp server environment.

This is my method for enabling Virtual Hosts on my wampserver on my own local machine but I don't see why it wouldn't work for any old Apache installation. If you have trouble with it, leave me a message in the comments below and I'll be happy to help.

Step 1: Open your hosts file.

  1. Navigate to your hosts file normally located in \WINDOWS\system32\drivers\etc\hosts
  2. Open the file named hosts (no extension) with notepad.
  3. Add this line to the bottom:
    127.0.0.1        testsite
    This tells your computer that any url with a value of 'testsite' should be routed to 127.0.0.1 or more commonly refered to as localhost aka your own machine.
  4. Next, open httpd.conf located in \apache\conf\httpd.conf
    If you installed wamp server this is located at \wamp\bin\apache\apache2.2.6\conf
  5. At the very bottom add these lines:

  6. Restart apache and you should be able to type http://testsite/ into any browser (may need to restart that too) and it will show you the DocumentRoot you just set.

The first line, NameVirtualHost *:80 tells Apache to look out for virtual hosts using its own naming convention. The next couple lines set up a virtual host. You can use as many of these as you want and set up as many sites as you may be developing at one time. Personally, I find this method to be invaluable.. I hope it helps someone else out there.

Get my RSS Feed!

Comments

works on (7.24.24 11:33 am) says

This is exactly what I needed!  Thanks!

 

Rajeev Kamal on (7.31.31 8:14 am) says

GR8 , i killed almost one day to see, how i can make my multiple joomla installation work on same machine as i will use no-ip.com for this. Now i will need to disable my default localhost so that no one alter as the phpmyadmin options are still available from internet.

 

Rajeev Kamal on (7.31.31 8:23 am) says

can you help me further.
after creating the virtual hosts i want to be able to run my multiple site with the no-ip.com free service. can you guide how to go ahead with this.

 

michael on (12.15.15 6:48 pm) says

how can my site may be viewed worldwide?

 
* Name
* Email (Will not be displayed)
Website