Creating a Virtual host on Wamp

Run any of your favourite text editor as an administrator (I am using notepad++ in this case) Navigate to the filename "host" in the path  C:Windows/System32/drivers/etc .You will need to change the setting of filetype from txt to all files to see “hosts”.

In the host file you will see for some version of windows (7,8, Vista):   localhost    

or  windows(10)   localhost
::1 localhost   

This code tells your computer to connect to your own computer when we try to go to http://localhost
Now we should add our site (prefered servername) to this file. Let's say our site name is example1 (can be any name ). So we would add an entry for it in the hosts file. The updated file would look similar to the following for windows 7,8, Vista   localhost  

or for  windows(10)   localhost
::1 localhost  
Save this file and try going to http://example1 this would take you to the same page as http://localhost
Now our computer knows what http://example1 is.

Note: Make sure you do not add host entries for external sites like or If you add these entries, then the computer would no longer be able to go to the actual websites. Navigate to apache httpd.conf file by clicking on the wamp icon then apache  then httpd.conf from the drop-down menu
Add this to the end of the  file for 1  virtual host  called example1 (can choose  any name but make sure it is similar to name given in the host file above ) listening on port 9191 (Again you can use any desired port but make sure there is no conflict) you can add more  for more host:
remember to change the path to your project folder.

Listen 9191
NameVirtualHost *:9191
<VirtualHost *:9191>
    ServerName site1                                                  /*(same server name as written in the host file eg:site1)*/
    DocumentRoot "pathto your project folder"                        /*eg:D:projectsHealthbuk"*/
    <Directory "pathto your project folder ">                         /*eg:D:projectsHealthbuk"*/
            Options +Indexes +Includes +FollowSymLinks +MultiViews
            AllowOverride All
            Require local
            Allow From all

Save the file and restart apache now in your URL, access your new server by  http://servername:port

0 3


No Coments Available for This Post

Leave a Comment

Subscribe to our newsletter to get the latest News and offers..