+ Post New Thread
Results 1 to 7 of 7
Web Development Thread, Virtual Hosts in Apache (XAMPP on W2k3) in Coding and Web Development; I've seen this topic covered before so please forgive me but I'm having some real problems getting my head round ...
  1. #1
    jimothy's Avatar
    Join Date
    Mar 2008
    Location
    Shrewsbury
    Posts
    43
    Thank Post
    14
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Virtual Hosts in Apache (XAMPP on W2k3)

    I've seen this topic covered before so please forgive me but I'm having some real problems getting my head round virtual hosts. I understand the theory but can't get it working in practice.

    Scenerio:

    1 W2k3 server with XAMPP installed. 4 websites running from separate folders in htdocs.

    These all work well and can be browsed from http://servername/website. For a couple of the sites I would like them to use a virtual host. i.e. just hosted xibo so instead of browsing to http://servername/xibo I'd like to use http://xibo.mydomain.com.

    Setup an A name record in DNS to point http://xibo.mydomain.com to the servers IP. That's all cool. Read up from Apache how to modify the httpd-vhosts.conf file. Added the following and removed the ## from NameVirtualHost *:80 :

    Code:
    <VirtualHost _default_:*>
    	DocumentRoot C:\Xampp\htdocs
    </VirtualHost>
    
    <VirtualHost *:80>
    	DocumentRoot C:\Xampp\htdocs\xibo
    	ServerName xibo.mydomain.com
    </VirtualHost>
    The first host is to ensure anyother traffic gets directed at the root of the htocs folder. This works fine. If I browse to http://xibo.mydomain.com I get the root of the web server...

    What am I doing wrong guys?

    Fanks!

  2. #2


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    9,807
    Thank Post
    262
    Thanked 2,968 Times in 2,183 Posts
    Rep Power
    847
    The following works for me.

    Code:
    NameVirtualHost *:80
    
    <VirtualHost *:80>
    	DocumentRoot "C:\xampp\htdocs"
    	ServerName localhost
    </VirtualHost>
    
    <VirtualHost *:80>
    	ServerName xibo.mydomain.com
    	DocumentRoot "C:\xampp\htdocs\xibo"
    </VirtualHost>

  3. Thanks to Arthur from:

    jimothy (23rd October 2010)

  4. #3


    Join Date
    Feb 2007
    Location
    Northamptonshire
    Posts
    4,706
    Thank Post
    354
    Thanked 807 Times in 722 Posts
    Rep Power
    348
    I suspect the key bit missing is NameVirtualHost as Arthur has laid out above.

  5. Thanks to kmount from:

    jimothy (23rd October 2010)

  6. #4
    jimothy's Avatar
    Join Date
    Mar 2008
    Location
    Shrewsbury
    Posts
    43
    Thank Post
    14
    Thanked 1 Time in 1 Post
    Rep Power
    0
    Thanks for the replies. I've already uncommented the NameVirtualHost *:80 line and using the example Arthur has given sadly doesn't resolve my problem; in fact it makes it worse as none of the sites are accessible.

    I can't see what's wrong...

    Any other ideas?

  7. #5
    jimothy's Avatar
    Join Date
    Mar 2008
    Location
    Shrewsbury
    Posts
    43
    Thank Post
    14
    Thanked 1 Time in 1 Post
    Rep Power
    0
    This is all I have in my httpd-vhosts.conf file:

    Code:
    NameVirtualHost *:80
    
    <VirtualHost *:80>
    	DocumentRoot C:\Xampp\htdocs\xibo
    	ServerName xibo.concordcollege.org.uk
    </VirtualHost>
    And if I browse to xibo.concordcollege.org.uk I still get the root of the web server... grrr

    I've tested XAMPP on another system and have exactly the same in the httpd-vhosts.conf file and that works... my head hurts

  8. #6
    jimothy's Avatar
    Join Date
    Mar 2008
    Location
    Shrewsbury
    Posts
    43
    Thank Post
    14
    Thanked 1 Time in 1 Post
    Rep Power
    0
    Ok, got this sorted out now, working on this on a Saturday night! sad huh?

    Here's the working httpd-vhosts.conf file:

    Code:
    NameVirtualHost *:80
    
    <VirtualHost *:80>
    	DocumentRoot "C:\xampp\htdocs"
    	ServerName localhost
    </VirtualHost>
    
    <VirtualHost *:80>
    	DocumentRoot C:\Xampp\htdocs\xibo
    	ServerName http://xibo.concordcollege.org.uk
    </VirtualHost>
    That pesky little http:// fixed it! Bizarre huh? Hope this helps someone else in the future.

    Thanks to Arthur for the tips on sorting this out

  9. #7


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    9,807
    Thank Post
    262
    Thanked 2,968 Times in 2,183 Posts
    Rep Power
    847
    Glad you got it sorted in the end.

    Quote Originally Posted by jimothy View Post
    That pesky little http:// fixed it! Bizarre huh?
    Very strange. I added the domain name to my hosts file so maybe that's why it works without the http:// for me?



SHARE:
+ Post New Thread

Similar Threads

  1. [Hosting] Apache and virtual hosts
    By TechMonkey in forum Web Development
    Replies: 8
    Last Post: 7th August 2009, 02:52 PM
  2. Running moodle and mahara on same linux server - OUCH virtual hosts
    By reggiep in forum Virtual Learning Platforms
    Replies: 1
    Last Post: 1st June 2009, 02:50 PM
  3. Wildcards in Apache virtual server
    By FN-GM in forum How do you do....it?
    Replies: 1
    Last Post: 16th September 2008, 04:22 PM
  4. Virtual Apache Servers
    By FN-GM in forum How do you do....it?
    Replies: 6
    Last Post: 30th May 2008, 09:18 PM
  5. Apache Virtual Hosting
    By Steven in forum Wireless Networks
    Replies: 6
    Last Post: 26th May 2008, 12:27 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •