Picnic Website Code Tutorials

Wamp Server How To Create a Virtual Host Tutorial


I use Wamp to run PHP locally. The best way to set this up is to create a virtual host. In short, this points Wamp at your site where ever it happens to reside on your computer, vs having to move your site into the Wamp www folder. The following explains how to create a virtual host in Wamp.

Step 1: Open C:\wamp\bin\apache\Apache2.2.11\conf\httpd.conf and uncomment the virtual hosts include and save:

Create a Virtual Host in Wamp 1 Create a Virtual Host in Wamp 2

Step 2: Open your windows host file, C:\WINDOWS\system32\drivers\etc\hosts , and add the name you want to use for your virtual host.

Create a Virtual Host in Wamp 3

Step 3: Open C:\wamp\bin\apache\Apache2.2.11\conf\extra\httpd-vhosts.conf and add a “VirtualHost” block similar to below.

Create a Virtual Host in Wamp 4

In text form for easy copy and paste...

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot "D:/Workspace/Zagweb/robert/public_html/"
    ServerName rob
    ErrorLog "logs/your_own-error.log"
    CustomLog "logs/your_own-access.log" common
    <directory "D:/Workspace/Zagweb/robert/public_html/">
        Options Indexes FollowSymLinks
        AllowOverride all
        Order Deny,Allow
        Deny from all
        Allow from

Step 4: Done! Restart WAMP and you should now be able to access your site via the virtual host. Access the virtual site via http://rob/.

Create a Virtual Host in Wamp 5

Credit for tut. And here is another way to do the same thing.

Need help adding this or other code to your website? Post it here in the forum! Forum


Top Donators

Friends of Mine