Create virtual host on WAMP 3

Project Links do not work on Wamp Server!!!

In WampServer it is now recommended to create a Virtual Host for each of your projects, even if you hold them in a \wamp\www\subfolder structure. The WampServer home page ( \wamp\www\index.php ) now expects you to have created a Virtual Host for all your projects and will therefore work properly only if you do so.

How to create a Virtual Host in WampServer

There are 3 steps to create your first Virtual Host in Apache, and only 2 if you already have one defined.

-Create the Virtual Host definition(s)
-Add your new domain name to the HOSTS file.
-Restart the Apache service

Step 1, Create the Virtual Host definition(s)

Edit the file called httpd-hosts.conf which for WampServer lives in

\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf

I am assuming we want to create a definition for a site called project1 that lives in

\wamp\www\project1

Now we define our project: and this of course you do for each of your projects as you start a new one.

<VirtualHost *:80>
    DocumentRoot "c:/wamp/www/project1"
    ServerName project1
    <Directory  "c:/wamp/www/project1">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

Step 2:

Add your new domain name to the HOSTS file.

C:\windows\system32\drivers\etc\hosts

The hosts file should look like this when you have completed these edits

127.0.0.1 localhost
127.0.0.1 project1

::1 localhost
::1 project1

Now we must tell windows to refresh its domain name cache, so launch a command window using the Run as Administrator menu option, and do the following.

net stop dnscache
net start dnscache

Step 3:
To activate this change in you running Apache we must now stop and restart the Apache service.

wampmanager.exe -> Apache -> Service -> Restart Service

Leave a Reply

Your email address will not be published. Required fields are marked *