Run Multiple Websites in WAMP by creating Multiple Virtual Hosts

Print View Mobile View

Virtual hosting is a method that allows one to run multiple web sites on a local computer. After setting it up, you would be able to access each web site using its own domain name.

In this tutorial, I will show how you can do it on WAMP, but other products are very similar, so you won’t have problems porting this.

Step 1: Open hosts file, located in C:\Windows\system32\drivers\etc\hosts, in you favorite text editor. Add a line similar to the one below and save the file.		mysite

Basically, this tells Windows to resolve IP (which is localhost) to mysite.

For more sites, simply add more lines:		mysite		myothersite		localhost.localdomain

Step 2: Next, browse to C:\wamp\bin\apache\apache2.2.17\conf and open httpd.conf file in a text editor. In that, find a line that looks like this:

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

Uncomment it (remove the # symbol) and save it.

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

Step 3: Browse  to the folder C:\wamp\bin\apache\apache2.2.11\conf\extras and open httpd-vhosts.conf file in a text editor. Scroll to the end of the file and below code:

<VirtualHost *:80>
	ServerAdmin webmaster@localhost
	DocumentRoot "c:/wamp/www"
	ServerName localhost
	ErrorLog "logs/localhost-error.log"
	CustomLog "logs/localhost-access.log" common
<VirtualHost *:80>
	#ServerAdmin webmaster@mysite
	DocumentRoot "c:/wamp/www/mysite"
	ServerName mysite
	ErrorLog "logs/mysite-error.log"
	CustomLog "logs/mysite-access.log" common
	<directory "c:/wamp/www/mysite">
		Options Indexes FollowSymLinks
		AllowOverride all
		Order Deny,Allow
		Deny from all
		Allow from

You can see two directives for Virtual Host here. The first one preserves default localhost, so you can still access the WAMP dashboard, and the second one tells Apache where to look when a request for mysite is made. Rest of the code allows you to use .htaccess on this domain.

Now restart Apache server, and you should be able to access http://mysite to develop and test your site.

After completing this, you can run WordPress multisite on your local computer.

12 thoughts on “Run Multiple Websites in WAMP by creating Multiple Virtual Hosts”

Comments are closed.