Since I work from a local environment to do my development on web applications and work on a lot of projects at the same time I wanted a “cleaner” way I could access different projects without going through my WAMP control panel.

This cleaner way  also made demonstrations look more professional  because you can access the application directly as if it was already  “live”.

To do this I had to add virtual hosts for each of my projects and decided to share the steps with my fellow bloggers.

This virtual host allows you to host different projects with dedicated names like a domain name on one IP address which is similar to shared web hosting.

The steps to add the virtual host(s) are as follows:

 

NOTE: Make sure to have a working installation of WAMP already installed on your development machine, you can download WAMP on the link below:

www.wampserver.com/en/

 

STEP 1:

First we need to edit the httpd.conf file to include virtual hosts . To do this, open C:\wamp\bin\apacheXXX\conf\httpd.conf (XXX refers to your apache version number) and uncomment the Include under virtual hosts which can be found between line 464 and 467:

httpd_conf

 

STEP 2:

Now that we included virtual hosts with our apache config file we need the virtual host names to our host file. Open the host file, C:\Windows\System32\drivers\etc\hosts, and edit it to look like this:

 

hosts_file

 

For this example I used “clombo” as the host name, but you can add any name you like.

NOTE: Better to be safe and run Notepad, or the editor of your choice, as a administrator otherwise you might not be able to save the file afterwards.

 

STEP 3:

Finally you can add your “VirtualHost” blocks on your httpd-vhost.conf file which can be found under C: \wamp\bin\apache\ApacheXXX\conf\extra :

 

VirtualHosts

 

You can add similar blocks but make sure to add the correct hostname on “ServerName” and the path to your selected project on “DocumentRoot”

The localhost virtual block was added so that I still have access to my WAMP panel on http://localhost/

Now that we edited all the necessary files all you need to do is restart your WAMP server and you will be able to access the virtual host on http://clombo/

If you want to add more virtual hosts you can follow steps 2 and 3 again.

 

LAST NOTE: The VirtualHost blocks that we used are very basic and there are a lot more you can add to it if needed, so let your fingers do the searching on Google if you want more in the blocks :-).