Virtual Host on Windows with XAMPP

11 Comments
Tags: , , ,
Posted 10 Jan 2007 in How To
Advertisement

On my first tutorial we was try to Installing WordPress on Windows use XAMPP, this time I will give little help again how to tweak our local server, and make it Virtual Host enable. So we can develop many many website in one time and still in our windows local machine.

This tutorial also work on Mac OSX, Linux Desktop, FreeBSD Desktop with little tweak.

What we need?

XAMPP Logo

Let’s get started.

After XAMPP Installed, go to you XAMPP Installed folder. After opened try to edit this file with Notepad++ for more easy way or use Notepad for old way..

Apache > Conf > Extra > httpd-vhosts.conf

After that, try to look this original configuration

#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <url :http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
##NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <virtualhost> block.
#
##</virtualhost><virtualhost *:80>
##    ServerAdmin webmaster@dummy-host.example.com
##    DocumentRoot /www/docs/dummy-host.example.com
##    ServerName dummy-host.example.com
##    ServerAlias www.dummy-host.example.com
##    ErrorLog @rel_logfiledir@/dummy-host.example.com-error_log
##    CustomLog @rel_logfiledir@/dummy-host.example.com-access_log common
##</virtualhost>
##<virtualhost *:80>
##    ServerAdmin webmaster@dummy-host2.example.com
##    DocumentRoot /www/docs/dummy-host2.example.com
##    ServerName dummy-host2.example.com
##    ErrorLog @rel_logfiledir@/dummy-host2.example.com-error_log
##    CustomLog @rel_logfiledir@/dummy-host2.example.com-access_log common
##</virtualhost>
#<virtualhost *:80>
#    ServerAdmin webmaster@lab.lokal
#    DocumentRoot "C:/Program Files/xampp/htdocs/lab"
#    ServerName lab.lokal
#    ErrorLog @rel_logfiledir@lab.lokal-error_log
#    CustomLog @rel_logfiledir@lab.lokal-access_log common
#</virtualhost>
#<virtualhost *:80>
#    ServerAdmin webmaster@localhost
#    DocumentRoot "C:/Program Files/xampp/htdocs/smf"
#    ServerName localhost
#    ErrorLog @rel_logfiledir@localhost-error_log
#    CustomLog @rel_logfiledir@localhost-access_log common
#</virtualhost>

Look on that code, is that really long code and if work in Apache, if code have this # the code didn’t executed by Apache server.

Now we will try to add one virtual host, just edit all code above become like this below.

NameVirtualHost *:80
<virtualhost *:80>
    ServerAdmin sampe@mysample.com
    DocumentRoot "C:/Program Files/xampp/htdocs"
    ServerName localhost
</virtualhost>
<virtualhost *:80>
    ServerAdmin webmaster@mywordprees.com
    DocumentRoot "C:/wordpress"
    ServerName www.wordpress.local
    ServerAlias wordpress.local
    <directory "C:/wordpress">
        AllowOverride FileInfo AuthConfig Limit Indexes
        Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
        <limit GET POST OPTIONS>
            Order allow,deny
            Allow from all
        </limit>
        <limitexcept GET POST OPTIONS>
            Order deny,allow
            Deny from all
        </limitexcept>
    </directory>
</virtualhost>

On code above I try add two virtual host, the first one for take original http://localhost, and the second one for my WordPress virtual host http://wordpress.local

After code was completed, safe and exit.

Now, the magic time, in windows and many Operating Sytem, before they looking another DNS Server, many OS will check they hosts list on they machine, so let add new domain to our hosts machine.

Open you fave editor (Notepad++) for me, and Open File on this folder

C:\WINDOWS\system32\drivers\etc\

And select hosts
You will find this code

# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

127.0.0.1       localhost

That original Windows hosts, and this the time to add some host on you local machine to enable virtual host, below 127.0.0.1 localhost add this

127.0.0.1       wordpress.local
127.0.0.1       www.wordpress.local

That all, after that restart you Apache and try to point you Browser to new address, and holla you are dona add virtual host on you own local machine.

Popularity: 45%

Share and Enjoy:
  • del.icio.us
  • Facebook
  • Digg
  • Reddit
  • BlinkList
  • NewsVine
  • Print
  • LinkedIn
  • StumbleUpon
  • Sphinn
  • Yahoo! Buzz
  • FriendFeed
  • HelloTxt
  • Google Bookmarks
  • Suggest to Techmeme via Twitter
  • Technorati
  • email
  • PDF

virtual host on windows with xampp indodx

On my first tutorial we was try to Installing WordPress on Windows use XAMPP, this time I will give little help again how to tweak our local server, and make it
Source: http://blog.indodx.com/archives/virtual-host-on-windows-with-xampp.jsp

setting up virtual hosts with xampp running on windows xp

Setting up Virtual Hosts with XAMPP running on Windows XP. 2008 Jul 30 This document assumes that you are working with Windows XP with XAMPP.
Source: http://www.tildemark.com/software/servers/setting-up-virtual-hosts-with-xampp-running-on-windows-xp.html

sawyer mcfarland media inc

Virtual Hosts give you the ability to "host" more than one Web site and domain on your on the Virtual Host feature on Apache, and set up the C:\xampp\htdocs
Source: http://www.sawmac.com/xampp/virtualhosts/index.php

set up multiple virtual hosts on xampp for windows mafflog

1. Create the virtual host entries. This how-to is based on the actual version (1.6.7) of XAMPP. on 2008-11-12 Set up multiple virtual hosts on XAMPP for windows
Source: http://maff.ailoo.net/2008/07/set-up-multiple-virtual-hosts-on-xampp-for-windows/

windows otda xampp yordamida virtual host yaratish uzblogger

Windows OTda XAMPP yordamida Virtual Host yaratish. Posted on 28-Avgust, 2008 by Avaz Endi mana shu virtual hostni Windows operatsion tizimida XAMPP yordamida o rnatishni o
Source: http://www.uzblogger.com/2008/08/28/windows-otda-xampp-yordamida-virtual-host-yaratish.html

how to config virtualhosts with xampp? programming

I have got XAMPP installed at home on XP Pro and I am trying to figure out how to setup multiple sites on my computer using virtual hosts. The windows hosts file does not
Source: http://forums.whirlpool.net.au/archive/569991

localhost unreachable after setting up virtual hosts hosts

Hi, When I typed http://localhost in my browser it used to go to C:\xampp\htdocs. But now I added a virtual host. The Windows hosts file now looks like this: 127.0.0.1 localhost
Source: http://www.experts-exchange.com/Microsoft/Applications/Virtual_Server/Q_24175350.html

set up multiple virtual hosts on xampp for windows mafflog

IT stuff and more As I work on many projects and experiments on my local windows development environment , I normally put all web stuff in the htdocs directory and usually I’m
Source: http://maff.ailoo.net/2008/07/set-up-multiple-virtual-hosts-on-xampp-for-windows/

i justrealized » blog archive » how to set up virtualhost in

My environment is Windows Vista but these instructions work for Windows XP as well. I also written a guide on how to set up virtual hosts in Ubuntu.
Source: http://i.justrealized.com/2008/05/16/how-to-set-up-virtualhost-in-xampp-for-windows/

nullvoid » xampp virtual host

xampp virtual host has any problems with XAMPP this is the exact process I followed to get it working. I added these lines to my Windows Hosts file (c:\windows
Source: http://blog.mikezhang.com/2006/12/25/xampp-virtual-host


9 Comments

  1. Like your tutorial.
    Got Virtual Host running.

    Thanks

  2. Great post, was very helpful in setting up my multiple hosting arrangement.
    Took some sorting out to make sure it would work, so I thought I’d share what I did here.

    I was using xampp, so added the details in the http-vhosts.conf file, saved, then tried to restart – and apache just wouldn’t restart. Deleted everything I had changed and it worked fine. But I didn’t have the multiple hostings.

    I took a look through the info on the Apache website, and read through the httpd.conf file, and then realised a couple of things.

    The first entry in your http-vhosts.conf file must have exactly the same detail as what’s in your httpd.conf file.

    Also, I don’t think I realised that the DocumentRoot had to be in “Inverted Commas” – they are in your post, I just don’t think I recognised that at the time.

    But I’ve now got it set up and will be hosting my websites from there soon!

  3. Franz

    This works great! You just made me so much more productive.

  4. Jesse

    I have a server running on linux, but I want to run an XAMPP server too.

    How can I set it up so that I can access the XAMPP server remotely?

    Is there a way to change the adress to access the server?

    (anyway, thanks for the tut. :D)

  5. WTF? Do you use XAMPP? Does it require conf editing? Oh guys, visit russian site denwer.ru . If it’s difficult to you to understand it, go directly
    http://www.denwer.ru/dis/Base/Denwer3_Base_2008-01-13_a2.2.4_p5.2.4_m5.0.45_pma2.6.1.exe
    it will create sites and subdomain as fast as you add diretory to Z:\home\yoursitename\www\ + all alias.
    It’s really easy to test locally ;)

  6. bryant

    I didnt use:
    Apache > Conf > Extra > httpd-vhosts.conf
    just to make it work. Although I want to place it there. The problem is I cant make it work. I havent tried:

    “The first entry in your http-vhosts.conf file must have exactly the same detail as what’s in your httpd.conf file.” as suggested by Ben. So my hosting entry is on httpd.conf. And of course, I set the hosts file on Windows.

  7. Thanks, works great for me on Vista 32-bit. I’ve been trying to figure out vhosts forever!

  8. epox

    if you copy this text directly and edit your settings, you should get in trouble because the ” are not correctly parsed, i retyped the ” and it works

  9. To get the best value for money, there are several things to look out for in a web hosting service provider.
    This is a very important aspect to consider when choosing your web hosting service provider.


2 Trackbacks/Pingbacks

  1. Jauhari Didetik | Seting Virtual Host di XAMPP Windows 22 06 08
  2. links for 2008-06-24 | Conteúdo Interativo 24 06 08

Add Your Comment

We Are DoFollow, it' mean No Follow Free ;)