Hosting multiple local sites with XAMPP

I would like to make an additional in terms of up to date information.

XAMMP uses port 80 by default and we are able to publish 1 website. I also use IIS for .Net projects. In this respect, I set the port to XAMMP except the 80 port. So I avoid a conflict.

When we want to publish more than one website, we should do the following operations to httpd.conf (this is the current name).

1. Setting the ports

Find the #Listen expression in the httpd.conf file. Change Listen 80 to Listen 8000 (or whatever else you want)

Listen 8000

If you need 3 different websites, type the others, including 1 definition on each line, as follows.

Listen 8001
Listen 8002
Listen 8003

2. Define the file paths of sites accessed through ports

Again, find in the httpd.conf file. Identify the folders of each website as follows. As you would see, I've created 3 directories called 8000, 8001, 8002 and 8003 under the htdocs directory within the XAMMP directory.

<VirtualHost *:8000>
 DocumentRoot "C:\XAMPP\htdocs\8000"
 ServerName localhost:8000
<\ VirtualHost>
<VirtualHost *:8001>
 DocumentRoot "C:\XAMPP\htdocs\8001"
 ServerName localhost:8001
<\ VirtualHost>
<VirtualHost *:8002>
 DocumentRoot "C:\XAMPP\htdocs\8002"
 ServerName localhost:8002
<\ VirtualHost>
<VirtualHost *:8003>
 DocumentRoot "C:\XAMPP\htdocs\8003"
 ServerName localhost:8003
<\ VirtualHost>

Restart your Apahche server on XAMMP. You can now view your 3rd site, such as http://localhost:8003 or http://192.168.1.1:8003/.

Hope to be useful.


This question was asked almost ten years ago, and the answers above are a bit dated. Note that XAMPP has a "How-To" for virtual hosts avilable off the dashboard, when you install it.

From the "Welcome to XAMPP for Windows" page (localhost/dashboard, the default when you first load localhost) click on the "HOW-TO" Guides in the top menu bar. From there, look for the link "Configure Virtual Hosts" which will lead you to the localhost page "http://localhost/dashboard/docs/configure-vhosts.html"

In a nutshell, the process involves editing the "httpd-vhosts.conf" file (typically in C:\XAMPP\apache\conf\extra) and replacing the contents of that file with something like this:

<VirtualHost *:80>
        DocumentRoot "C:/xampp/htdocs/"
        ServerName localhost
</VirtualHost>

# vhosts - note sample entry from XAMPP how-to throws an error, so try this:
<VirtualHost *:80>
        DocumentRoot "C:/Users/jdoe/Documents/dev.mysite.com/htdocs"
        ServerName mysite.local
        <Directory "C:/Users/jdoe/Documents/dev.mysite.com/htdocs">
            Require all granted
            Options Indexes FollowSymLinks
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
</VirtualHost>

Additional vhosts (including SSL hosts) can be had by cloning the entry, and modifying DocumentRoot and ServerName directives and port numbers (e.g. 443 for TLS (SSL)). You can find tutorials on the web for creating and signing your own certificate, if you want to go that route.

The final step is to get your Windows machine to point your browser to the Apache host for your virtual domain (e.g. above, http://mysite.local). Using a text editor (Notebook will do) as administrator append the following entry onto your hosts file, which lives here:

C:\Windows\System32\drivers\etc\hosts

Append this entry to the hosts file:

127.0.0.1           mysite.local

IMPORTANT - you must restart your Windows machine or the new host will not respond. Some documentations will tell you just to restart the browser and Apache server, but I've found that's not sufficient.

IME, the hosts system and Apache directives can be particular, so be patient. You may need to rebuild configs, restart Apache, and restart your machine more than once.


Greg, you're almost there--you need (like Moses said) to setup virtual hosts.

So if your Windows hosts file has

127.0.0.1    localhost
127.0.0.1    mysite-dev.com
127.0.0.1    anothersite-dev.com

Your virtual hosts file (httpd-vhosts.conf) might look like:

<VirtualHost *:80>
  DocumentRoot C:/xampp/htdocs/
  ServerName localhost
</VirtualHost>

<VirtualHost *:80>

    ServerName mysite-dev.com

    DocumentRoot "C:/sites/mysite-dev"

    <Directory "C:/sites/mysite-dev">
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

</VirtualHost>

<VirtualHost *:80>

    ServerName anothersite-dev.com

    DocumentRoot "C:/sites/anothersite-dev"

    <Directory "C:/sites/anothersite-dev">
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

</VirtualHost>

Don't forget to restart the web server after you make any changes.