Create Virtual Host in XAMPP...

by Lasantha Samarakoon on Friday, December 25, 2009

XMAPP is one of the main easy to install Apache distribution which containing MySQL, PHP, Mercury Mail Transport System, Filezilla and etc. And this package is available for many operating systems such as Microsoft Windows, Linux, Mac OS X and Solaris. And the good thing is it’s a freeware. So you can download it free of charge from here.

If you want to use XAMPP, you need to host your web pages and files in XAMPP web folder, which is known as “htdocs”. You can access this folder throw your browser by typing http://localhost in the address bar. So instead of that today I am going to show you how to create another directory in your hard drive and host it in XAMPP. Steps are as follows.

Create a folder in your HD which is going to use as the root directory. As an example I will create a directory in the D:\Virtual\myroot\. So “myroot” will be my new root directory.

1. Open XAMPP installed directory.

2. Go to apache -> conf -> extra directory.

3. In the extra directory there is a file called “httpd-vhosts.conf”. Open it in text editor such as NOTEPAD.

    DocumentRoot "D:/Virtual/myroot/"
    <Directory D:/Virtual/myroot/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all

4. Save and close the file.

5. Now go to the "Windows" folder. Open System32 -> drivers -> etc folder.

6. In the “etc” directory, there is a file called “hosts”. Open it in a text editor.

7. At the end of the file append following text.

8. Save and close the file. Sometimes your anti-virus program will block saving. In that kind of situation, allow it.

9. Go to “XAMPP Control Panel” and stop and restart the Apache service.

10. Open your preferred browser and type

11. You can see the content of you new virtual host.