How to configure virtual hosts in xampp on windows OS

May 4, 2010 at 11:09 AM (Various Configs)

I am writing a quick tutorial for configuring virtual hosts in xampp server on windows OS. This will help beginners to create virtual hosts with in a few minutes. I have little time so I am taking you straight down to the point –

What do you need –

1. Xampp server for windows download it from http://www.apachefriends.org/en/xampp.html

How to install –

Just run the latest downloaded version of xampp.exe and follow the instructions.

Configuring Virtual Hosts –

1. Go to [PATH_TO_XAMPP_FOLDER]\xampp\apache\conf\extra\

2. Open the file ‘httpd-vhosts.conf‘ file

3. If you have not modified this file before then you will find every line is started with a ‘#’ hash sign. It means all these lines are comment lines.

4. So copy the following code as given below and add it at the end of file –

NameVirtualHost 127.0.0.1:80

<VirtualHost 127.0.0.1:80>

DocumentRoot C:/xampp/htdocs/
ServerName localhost

<!–VirtualHost>

<VirtualHost 127.0.0.1:80>

DocumentRoot C:/xampp/htdocs/host_wordpress/
ServerName http://www.mywordpress.foryou

</VirtualHost>

5. Save the file.

6. Please check out the bold text host_wordpress it means you must create a folder in xampp/htdcos/ folder.

7. So create a folder named host_wordpress there.

8. Now go to C:\WINDOWS\system32\drivers\etc\ folder location

9. Copy the file hosts and paste it there for a back up. So if anything goes wrong then you could come back to a default state later.

10. Now open the hosts file.

11. Find the line 127.0.0.1       localhost

12. Under this line write the following

127.0.0.1     http://www.mywordpress.foryou

13. Save the file.

14. Go to C:\xampp\htdocs\host_wordpress folder

15. Create an index.php file.

16. If apache is running then restart apache using the xampp control panel.

17. hit the url – http://www.mywordpress.foryou

18. If you have done everything correctly you will get the output of the index.php file in you server.

This slideshow requires JavaScript.

Hope this really help you.

A small piece of advice – Learn web programming *nix rather in windows. You will learn more in a very short span of time.

Have fun.

Permalink Leave a Comment