Nov 06 2011

Howto: Virtual Hosts in Apache

Case:
You would like to develop several web sites on your Windows workstation.

Solution:
WAMP Server installation of Apache has Virtual Host definitions in a separate conf file. First you need to uncomment the include in httpd.conf:

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

Then write the definition in the httpd-vhosts.conf file:

NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot "C:/your/website/root"
    ServerName your.website.name
</VirtualHost>

<Directory "C:/your/website/root">
    Options Indexes FollowSymLinks
	AllowOverride all
	Order Deny,Allow
	Deny from all
    Allow from 127.0.0.1
</Directory>

Now add your web site name to the hosts file:

127.0.0.1       localhost
127.0.0.1       your.website.name

Restart Apache and now you may access the local version of the web site using the URL http://your.website.name.

Leave a Reply