Forum Moderators: phranque

Message Too Old, No Replies

VirtualHost problem

Apache uses only the first <VirtualHost> for all domains

         

bmorel

10:28 am on May 23, 2005 (gmt 0)

10+ Year Member



Hello all,

I've just installed apache 2.046
I was before on apache 1.3, and my sites worked perfectly.

Here is a summary of my httpd.conf :

<--------------------------------------->

DocumentRoot "/var/www/html"

NameVirtualHost *:80

<VirtualHost *:80>
ServerName site1.com
DocumentRoot /home/user1/site1.com
ServerAlias www.site1.com
</VirtualHost>

<VirtualHost *:80>
ServerName site2.com
DocumentRoot /home/user2/site2.com
ServerAlias www.site2.com
</VirtualHost>

<--------------------------------------->

Whatever domain I'm trying to access, apache uses the first virtualhost to answer.

Moreover, a "httpd -S" gives me a segfault, but if I comment the line "NameVirtualHost *:80", I get a Syntax OK. Maybe it's an apache bug, but I don't think it's my machines (same pb on 2 machines, and seen the same segfault problem on a google search, without answers though...)

Does someone have an explanation to this?

Thanks a lot.
Ben

mack

4:19 am on May 24, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Try adding
<VirtualHost *>

as oposed to
<VirtualHost *:80>

The "*" acts as a wild card so it will allow from any port. But Apache is set at default to listen on port 80.

Mack.

bmorel

8:40 am on May 24, 2005 (gmt 0)

10+ Year Member



Mack, thanks for your answer.
I already tried this, but it doesn't work.
I've just found how to make it work: I need to explicitly put <VirtualHost my.ip:my.port>
Don't know why, but it seems to work now.