Setting up Virtual Hosts with XAMPP running on Windows XP

2008 Jul 30
virtual.gifSetting up virtual hosts with XAMPP is very straight forward and could be done in less than 5 minutes. Although, your local XAMPP server will still work even if virtual hosts are not configured. You might want to ask, is there a need for my local XAMPP setup to configure virtual hosts? Apparently, virtual hosts are needed when

  • your on multiple domains
  • your need to test your projects with same configuration with the server
  • test your projects without touching your public server
  • your just organizing your projects into groups
  • or setup a local copy of your blog or website
What do we need?
This document assumes that you are working with Windows XP with XAMPP. If you don't have XAMPP, get it at their XAMPP for Windows download page. Just execute the exe file and follow the onscreen instructions.

Configuring Windows XP to accept hosts
Hosts is a file under Windows XP that is used to map IP addresses to a custom list of hosts or maybe domain names. The IP address should be placed in one line. The first column should contain the IP address and on the second column its corresponding hostname. The IP address may be separated by a space or by a tab. You can place comments by prepending your line this symbol '#' (pound sign). Initially the first line is added. Now lets add our domain tildemark.com

127.0.0.1       localhost
127.0.0.1       tildemark.com
127.0.0.1       tildemark.com

you can check your work by doing a ping to your configured host.
pinging-tildemark.com.jpg 

Configuring XAMPP to accecpt Virtual Hosts
  1. Got to your Apache folder in XAMPP and locate the conf files. The are usually located at <>\xampp\apache\conf\extra
  2. Open the file named httpd-vhosts.conf with a text editor
  3. If posible read the instructions so may have the idea on what you are doing
  4. Now paste the following code at the bottom of the file without touching the document.

    NameVirtualHost 127.0.0.1:80

      DocumentRoot E:/xampp/htdocs/    # change this line with your htdocs folder
      ServerName localhost


  5. Edit the line DocumentRoot with your own document root folder
  6. For each domain you are to configure paste the following lines below, just replace my domain name your corresponding domain:

  DocumentRoot "E:\www\tildemark.com"
  ServerName tildemark.com
  ServerAlias tildemark.com

  CustomLog "E:\www\tildemark.com\tildemark.com-access_log" combined
  ErrorLog "E:\www\tildemark.com\tildemark.com-error_log"

 
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
 




Tweet this post

Related Entries

Leave a comment


Recent Entries

Close