Apache Virtual Hosts (Very Confused)

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

Apache Virtual Hosts (Very Confused)

Postby designermonkey » 17. May 2010 16:02

I have set up some Virtual Hosts on my machine with the following configuration:
Code: Select all
NameVirtualHost 127.0.0.1:80
NameVirtualHost 0.0.0.0:80

<VirtualHost 0.0.0.0:80 127.0.0.1:80 localhost>

   DocumentRoot C:/xampp/htdocs/
   ServerName localhost
 
</VirtualHost>
<VirtualHost 0.0.0.0:80 127.0.0.1:80 testserver1>

   DocumentRoot C:/projects/testserver1/
   ServerName testserver1
   ServerAlias testserver1
    
   <Directory "C:/projects/testserver1">
      Options Indexes FollowSymLinks
      AllowOverride All
      Order allow,deny
      Allow from all
   </Directory>
 
</VirtualHost>
<VirtualHost 0.0.0.0:80 127.0.0.1:80 testserver2>

   DocumentRoot C:/projects/testserver2/
   ServerName testserver2
   ServerAlias testserver2
    
   <Directory "C:/projects/testserver2">
      Options Indexes FollowSymLinks
      AllowOverride All
      Order allow,deny
      Allow from all
   </Directory>
 
</VirtualHost>

Private IP changed for 0.0.0.0

I have also added each one into my hosts file, which is correct as I can ping each one successfully.

The problem I have is that the first two work, and also work from other computers that have the correct ip in the hosts file. However the third one doesn't. It has taken me all day of trawling through tutorials on how to set this up to get it to work for the first two. I'm at my wits end with this, it is so confusing!

I have had to put the ip's in the way I have to get them to work accross the network, yet it still isn't working correctly!

Any ideas??
designermonkey
 
Posts: 7
Joined: 17. May 2010 10:14

Re: Apache Virtual Hosts (Very Confused)

Postby BigWetDog » 17. May 2010 16:44

First off can I suggest that unless have more than one external IP that you might consider configuring as such:
Code: Select all
NameVirtualHost *:80  # listen on all interfaces (loopback and nic1) on port 80

<VirtualHost *:80>
   ServerName localhost
   DocumentRoot C:/xampp/htdocs/ 
</VirtualHost>

<VirtualHost *:80>
   ServerName testserver1   
   ServerAlias testserver1
   DocumentRoot C:/projects/testserver1/
     
   <Directory "C:/projects/testserver1">
      Options Indexes FollowSymLinks
      AllowOverride All
      Order allow,deny
      Allow from all
   </Directory> 
</VirtualHost>

<VirtualHost *:80>
   ServerName testserver2
   ServerAlias testserver2
   DocumentRoot C:/projects/testserver2/ 
   
   <Directory "C:/projects/testserver2">
      Options Indexes FollowSymLinks
      AllowOverride All
      Order allow,deny
      Allow from all
   </Directory> 
</VirtualHost>



And you really shouldn't need the ServerAlias directives.
User avatar
BigWetDog
 
Posts: 148
Joined: 25. February 2010 15:54

Re: Apache Virtual Hosts (Very Confused)

Postby designermonkey » 17. May 2010 17:04

Ok, so I've tried that, and agree as that is how all the documentation says to do itbut it doesn't work. All the requests then go to localhost only.

I'm really starting to fall out with this stuff...
designermonkey
 
Posts: 7
Joined: 17. May 2010 10:14

Re: Apache Virtual Hosts (Very Confused)

Postby designermonkey » 17. May 2010 17:18

Ok so here is a thinned out version that works for my PC but none others on the network

Code: Select all
NameVirtualHost 127.0.0.1:80
NameVirtualHost 0.0.0.0:80

<VirtualHost localhost>
   ServerName localhost
   DocumentRoot C:/xampp/htdocs/
</VirtualHost>

<VirtualHost 0.0.0.0:80 thomascookstyle>
   ServerName thomascookstyle
   DocumentRoot C:/projects/thomascookstyle/
   <Directory "C:/projects/thomascookstyle">
      Options Indexes FollowSymLinks
      AllowOverride All
      Order allow,deny
      Allow from all
   </Directory>
</VirtualHost>

<VirtualHost 0.0.0.0:80 ftc-symphony>
   ServerName ftc-symphony
   DocumentRoot C:/projects/ftc-symphony/
   <Directory "C:/projects/ftc-symphony">
      Options Indexes FollowSymLinks
      AllowOverride All
      Order allow,deny
      Allow from all
   </Directory>
</VirtualHost>


Like I say, this works for all three locally, but not accross the network. Are there any settings elsewhere that affect the way this works? I'm going to play on another computer on another network to see if this works there... I seriously doubt it will though...
designermonkey
 
Posts: 7
Joined: 17. May 2010 10:14

Re: Apache Virtual Hosts (Very Confused)

Postby BigWetDog » 17. May 2010 18:23

Let's see your hosts file entries.
User avatar
BigWetDog
 
Posts: 148
Joined: 25. February 2010 15:54

Re: Apache Virtual Hosts (Very Confused)

Postby designermonkey » 17. May 2010 18:35

I'll post it in the morning when I'm in the office again...

Thanks so far!
designermonkey
 
Posts: 7
Joined: 17. May 2010 10:14

Re: Apache Virtual Hosts (Very Confused)

Postby BigWetDog » 17. May 2010 19:31

Okay. I'm experimenting with the vhosts configuration in my environment and I"m running into similar issues.
User avatar
BigWetDog
 
Posts: 148
Joined: 25. February 2010 15:54

Re: Apache Virtual Hosts (Very Confused)

Postby JonB » 17. May 2010 21:06

Try putting the Directory directive before the VirtualHost directive.

:idea:
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Apache Virtual Hosts (Very Confused)

Postby BigWetDog » 18. May 2010 01:20

Got it!
Short answer:
modify xampp/tomcat/conf/mod_jk.conf, changing:
Code: Select all
<VirtualHost localhost>

to
Code: Select all
<VirtualHost *:80>

and in your httpd-vhosts.conf use:
Code: Select all
NameVirtualHost *:80

as in the example I posted earlier.

Long answer:
If you execute from the apache/bin:
Code: Select all
httpd -D DUMP_VHOSTS

You might see:
Code: Select all
[::1]:80               localhost (<DRIVE>:/xampp/tomcat/conf/mod_jk.conf:12)
127.0.0.1:80           localhost (<DRIVE>:/xampp/tomcat/conf/mod_jk.conf:12)

This is the result of the installation of the Tomcat addon.
Looking in the specified mod_jk.conf file there is the <VirtualHost localhost>.
I changed that to put it in agreement with the httpd-vhosts.conf NameVirtualHost and all is well.
User avatar
BigWetDog
 
Posts: 148
Joined: 25. February 2010 15:54

Re: Apache Virtual Hosts (Very Confused)

Postby designermonkey » 18. May 2010 09:51

I'm in such a good mood now! Thanks BigWetDog, you've made my day. I spent all day trying to figure this out yesterday, never even twigged it would be TomCat as that is on different ports...

Brilliant!
designermonkey
 
Posts: 7
Joined: 17. May 2010 10:14

Re: Apache Virtual Hosts (Very Confused)

Postby BigWetDog » 18. May 2010 15:15

Yes, it is on a different port, but since you are using the mod_jk connector it's also available through httpd on port 80. If you don't need it to be then you can also comment out
Code: Select all
Include "/xampplite/tomcat/conf/mod_jk.conf"

in your httpd.conf. I think there is also an option to disable it if you run setup_xampp.bat
Cheers!
User avatar
BigWetDog
 
Posts: 148
Joined: 25. February 2010 15:54


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 117 guests