, 7 Guests, 1 Bot


Print This Post Print This Post

xampp virtual hosts

In the process of setting up my web server to host my blog and web page I was trying to figure out how to make this work.  After consulting an Apache manual it gave me a good idea of how to add virtual hosts into the httd.conf file.  However xampp is a little different and uses a vhost.conf file to configure the virtual hosts.  To add hosts to the vhost.conf file is relitively easy using the following format.  First the vhost.conf file is located in the /xampp/apache/conf/extras folder.  It will have the basic format already typed in you just have to modify and uncomment the lines.  It will look like the following:

# 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 *:80>
##    ServerAdmin
##    DocumentRoot /www/docs/
##    ServerName
##    ServerAlias
##    ErrorLog @rel_logfiledir@/
##    CustomLog @rel_logfiledir@/ common

Basically just some tweaking of this example will square you away.  There are several ways to do it and I used the host name method to build the virtual hosts.  Before you configure this file you should back it up and also create the directories that you will install the web pages to, remember they need to be in two seperate directories.  Once I did that I simple edited the vhosts file the following way:

NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot c:/xampp/blog/
<Directory C:/xampp/blog>
Options Includes Follow SymLinks Indexes
AllowOverride All
Order allow,deny
Allow from all

The server name and document root are all pretty straight forward, but the <directory>  portion is used to address a permissions issues that is set forward in the httd.conf file.  I run xampp on a Windows machine and this works great.  I also saw parts where people added the server names into the Windows host file in c:\windows\system32\drivers\etc.  This will allow for access on that machine using the web browser, however I didn’t do this and allowed my dns to handle the resolution.  I have had no problems.  Finally it is important to know that once you build virtual hosts in the vhost file the web page configuration in the httd.conf file is no longer used.  So if you had a site already configured in that file you will need to add it as one of the virtual hosts.  I hope this will help anyone who is trying to learn virtual host using apache as part of the xampp installation.

Leave a Reply




You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Time limit is exhausted. Please reload the CAPTCHA.