How to run multiple websites on XAMPP on Windows

Last updated on October 18th, 2014 by Robert Abela. Filed under WordPress Admin Tips

If you are a WordPress plugin or WordPress theme developer, or provide professional WordPress support from time to time you need to run multiple WordPress websites on the same XAMPP installation on Windows.  Multiple websites running on the same Apache web server are called Virtual Hosts. In this easy to follow tutorial we explain how to setup multiple virtual hosts on XAMPP so you can run multiple WordPress websites on the same XAMPP installation.

Configure Virtual Hosts in XAMPP

  1. To add virtual hosts in XAMPP, or in other words, to configure multiple websites on XAMPP, open the Virtual Hosts Apache configuration file httpd-vhosts.conf  from C:\xampp\apache\conf\extra\
  2. Uncomment the below  line to enable name based virtual hosts on your XAMPP.
NameVirtualHosts *:80
  1. At the end of the file add the following 4 lines. These 4 lines are used to allow access to the XAMPP configuration pages (to access phpMyAdmin etc) by using the URL http://localhost
<VirtualHost *>
DocumentRoot "C:\XAMPP\htdocs"
ServerName localhost
</VirtualHost>
  1. For each other virtual host (website) you would like to configure on the XAMPP Apache web server, add the below code (using www.wpwhitesecurity.com as example).
<VirtualHost *>
 DocumentRoot "C:\XAMPP\htdocs\wppro"
 ServerName www.WPWhiteSecurity.com
 <Directory "C:\XAMPP\htdocs\wppro">
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
 Allow from all
</Directory>
</VirtualHost>
  1. By adding the above directives to httpd-vhosts.conf  (XAMPP virtual hosts configuration file), the Apache web server running on XAMPP knows that:
    1. The website files can be found in c:\xampp\htdocs\wppro (line 2)
    2. This website should respond to www.wpwhitesecurity.com (line 3)
    3. Allow everyone to access the content of the directory (line 4 to 7)
  2. To test and confirm that all the syntax in the Apache configuration is correct, run the httpd.exe process with the –t switch from the c:\xampp\apache\bin directory as seen in the below screenshot.

Configure the Windows Hosts File

Use the Windows Hosts file to redirect the traffic from your computer to the local installation of XAMPP rather than to the original website. E.g. while testing new WordPress changes for our website WP White Security.com, I add an entry in the Windows Hosts file to redirect requests from my browser to the local intallation of XAMPP. To learn on how to redirect traffic using Windows Hosts file, read our webmaster tip Configuring Windows Host Files.

Configuration example: Running multiple websites on XAMPP

If you would like to add more than one virtual host (website) to XAMPP, simple add more VirtualHost directives to the same file. In my testing environment I have the following websites set up:

  • www.WP White Security.com from c:\xampp\htdocs\wppro
  • www.wphandymen.com from c:\xampp\htdocs\wphandy

To have both websites and the XAMPP configuration pages (localhost) running on my XAMPP installation, I have the following in the XAMPP virtual hosts configuration file (httpd-vhosts.conf).

<VirtualHost *>
 DocumentRoot "C:\XAMPP\htdocs"
 ServerName localhost
</VirtualHost>

<VirtualHost *>
 DocumentRoot "C:\XAMPP\htdocs\wppro"
 ServerName www.WPWhiteSecurity.com
 <Directory "C:\xampp\htdocs\wppro">
 Order allow,deny
 Allow from all
 </Directory>
</VirtualHost>

<VirtualHost *>
 DocumentRoot "C:\XAMPP\htdocs\wphandy"
 ServerName www.wphandymen.com
 <Directory "C:\xampp\htdocs\wphandy">
 Order allow,deny
 Allow from all
 </Directory>
</VirtualHost>

WordPress Hosting, Firewall and Backup

This Website is:

7 comments

pratik 18/06/2014

Hi,

Thanks for this very nice and informative article!

I have question, after setting up wordpress on XAMPP server, I downloaded the my live website, and also added eCommerce functionality into it!

It’s running fine on local server which is xampp, which is a virtual host for it!

Now How do I transfer this website running on XAMPP to another virtual host for which I have the FTP credentials , and that is located at (e.g.) 111.111.11.11 IP adderess.?

Thanks in advance!

Robert Abela 29/06/2014

Hi Pratik,

Thank you for following us. To transfer a website from XAMPP to the live server, or from any other source you should do a normal WordPress backup on XAMPP and restore it on the Live server. If you are new to WordPress backup here is a list of articles we have related to WordPress backup: https://www.wpwhitesecurity.com/tag/wordpress-backup/.

Riyad 15/04/2015

Hi,

I’m using your code.

DocumentRoot “C:XAMPPhtdocsBandR”
ServerName http://www.2827home.com

Order allow,deny
Allow from all

DocumentRoot “C:XAMPPhtdocstest”
ServerName http://www.stocklunch.com

Order allow,deny
Allow from all

But using above code, always shows first website.

Means when I type stocklunch.com it shows 2827home.com…

Give me a solution.
Thanks in advance.

WP White Security 20/04/2015

Hi Riyad,

Not easy to find out the problem offhand. Email us and we will look into your configuration and see what is wrong.

Excellent tutorial. Got everything up and running without any hassle at all. Thank you!

maulik savaliya 17/04/2019

Thanks it’s solve my problem

Alfred 25/05/2019

I followed your tutorial – IT WORKED!! THANKS ALLOT- you really helped allot.

Leave a Reply

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