multiple virtual hosts

Problems with the Windows version of XAMPP, questions, comments, and anything related.

multiple virtual hosts

Postby ajbe » 09. March 2009 19:38

I have one website (bizvetter.com) successfully under development on my computer (local, not live) based on a tutorial I did and have started another development website. I didn't know how to set up more than one virtual host site when I started the second so I have just been working under a subdirectory of the original website. This was fine until the second website became more complex and so I have been trying to determine how to add it separately and move the files.

My problem (I think) is that my brother-in-law did the original XAMPP install on my computer and he modified the:
c:\programfiles\xampp\apache\conf\httpd.conf file by adding
<VirtualHost *:80>
ServerName http://www.bizvetter.com
ServerAlias bizvetter.com
DocumentRoot C:/Progra~1/xampp/htdocs/elgg1.2
# ErrorLog c:/temp/bv-error.log
# CustomLog c:/temp/bv-access common
# CustomLog c:/temp/bv-referer referer
</VirtualHost>

He also modified the:
C:\windows\system32\drivers\etc\hosts file to include
127.0.0.1 localhost http://www.bizvetter.com bizvetter.com

He never modified the
c:\programfiles\xampp\apache\conf\conf\extra\httpd-vhosts.conf file

This all worked great!

To add the second virtual host site, I have tried several combinations of steps including
1)adding another line for the drivers
127.0.0.1 localhost http://www.bizvetter.com bizvetter.com

while adding to the c:\programfiles\xampp\apache\conf\httpd.conf file
<VirtualHost *:80>
ServerName http://www.recipe.com
ServerAlias recipe.com
DocumentRoot C:/Progra~1/xampp/htdocs/
# ErrorLog c:/temp/recipe-error.log
# CustomLog c:/temp/recipe-access common
# CustomLog c:/temp/recipe-referer referer
</VirtualHost>

and 2) adding the driver as above and modifying the c:\programfiles\xampp\apache\conf\conf\extra\httpd-vhosts.conf file by uncommenting the line NameVirtualHost *:80

and adding these
<VirtualHost *:80>
ServerName http://www.bizvetter.com
ServerAlias bizvetter.com
DocumentRoot C:/Progra~1/xampp/htdocs/elgg1.2
# ErrorLog c:/temp/bv-error.log
# CustomLog c:/temp/bv-access common
# CustomLog c:/temp/bv-referer referer
</VirtualHost>

<VirtualHost *:80>
ServerName http://www.recipe.com
ServerAlias recipe.com
DocumentRoot C:/Progra~1/xampp/htdocs/
# ErrorLog c:/temp/recipe-error.log
# CustomLog c:/temp/recipe-access common
# CustomLog c:/temp/recipe-referer referer
</VirtualHost>

Each time I do this, I restart Apache. And each time it pushes me to the real website for recipe.com (not my local). It also has been asking me to verify authorization for XAMPP under the original bizvetter.com url and won't let me open the index. (That I forgot the admin and password is hopefully a non-issue if I can get the second virtual host working, I won't need to worry about forgetting it for the first which was just a tutorial website anyway).

Any suggestions on what combination of efforts I should/should not be doing? I can post my files but it would seem to take up a whole lot of space. Thanks.
ajbe
 
Posts: 4
Joined: 09. March 2009 19:08

Re: multiple virtual hosts

Postby Izzy » 10. March 2009 00:12

First of all lets establish the exact path to your files in the XAMPP installation as this is very important.

Is it:
C:\Program Files\xampp\

Or is it:
C:\programfiles\xampp\

Then we can move forward with a solution to your problem.
Last edited by Izzy on 12. March 2009 07:51, edited 1 time in total.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: multiple virtual hosts

Postby ajbe » 10. March 2009 18:54

It is:
C:\Program Files\xampp\

with the space.
ajbe
 
Posts: 4
Joined: 09. March 2009 19:08

Re: multiple virtual hosts

Postby Wiedmann » 10. March 2009 18:59

And each time it pushes me to the real website for recipe.com (not my local)

So you have to add an entry for recipe.com in your hosts file.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: multiple virtual hosts

Postby ajbe » 10. March 2009 19:22

I believe I did add an entry for recipe.com but that I did not write it correctly in my question.
In my meeage above, where I said I:
1)adding another line for the drivers
127.0.0.1 localhost http://www.bizvetter.com bizvetter.com

It should have said that I
1)adding another line for the drivers
127.0.0.1 localhost http://www.recipe.com recipe.com

Essentially, I had the two entries:
127.0.0.1 localhost http://www.bizvetter.com bizvetter.com
127.0.0.1 localhost http://www.recipe.com recipe.com

But it still took me to the real online (not local) recipe.com
ajbe
 
Posts: 4
Joined: 09. March 2009 19:08

Re: multiple virtual hosts

Postby Wiedmann » 10. March 2009 19:25

127.0.0.1 localhost http://www.bizvetter.com bizvetter.com

An URI is not valid in a hosts file.

(Verify the entries with "ping" in the shell)
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: multiple virtual hosts

Postby make-fun » 11. March 2009 11:25

Hi there,

change your host file to
Code: Select all
127.0.0.1 www.bizvetter.com bizvetter.com
127.0.0.1 www.recipe.com recipe.com

without the localhost or http://.

And in the VirtualHost you may wanna put a * before the domain
Code: Select all
ServerName http://www.bizvetter.com
ServerAlias *bizvetter.com

FireFox and alike will try and add a www. before recipe.com, but IE doesn't, so this is a bit of playing it save.

Other then that, the style "127.0.0.1 http://www.bizvetter.com bizvetter.com" is just short for 2 lines
Code: Select all
127.0.0.1 www.bizvetter.com
127.0.0.1 bizvetter.com
so your style is fine…

A good idea is, to add
Code: Select all
ErrorLog "C:/PathToEachDomainYouHave/error.log"
in the VirtualHost, so you can track errors better…

Cheers
make-fun
 
Posts: 31
Joined: 11. March 2009 04:21

Re: multiple virtual hosts

Postby ajbe » 11. March 2009 16:40

Thank you, all. I am up and running. And learning a lot as I go!
ajbe
 
Posts: 4
Joined: 09. March 2009 19:08


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 61 guests