Virtual hosts not working

CentOS 5
Apache 2.2.3


I've configured Apache with virtual hosting to run 3 domains, 2 pointing to:

/var/www/html/danny

..... and the 3rd pointing to:

/var/www/html/richmond

However, all requests for www.therichmondstudio.co.uk return pages from the
other domain: www.dannyisrael.co.uk

??

The domain 'therichmondstudio.co.uk' correctly resolves to the same IP as
the server machine as you can see from the 'dig' commands listed below.

Garry


*************** httpd config ******************************

ServerName danisrael.vm.bytemark.co.uk:80

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.therichmondstudio.co.uk
ServerAdmin garry [at] usableit.co.uk
DocumentRoot /var/www/html/richmond
</VirtualHost>

<VirtualHost *:80>
ServerName www.dannyisrael.com
ServerAdmin garry [at] usableit.co.uk
DocumentRoot /var/www/html/danny
</VirtualHost>

<VirtualHost *:80>
ServerName www.dannyisrael.co.uk
ServerAdmin garry [at] usableit.co.uk
DocumentRoot /var/www/html/danny
</VirtualHost>


*********************************************************
; <<>> DiG 9.3.3rc2 <<>> danisrael.vm.bytemark.co.uk
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 6970
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;danisrael.vm.bytemark.co.uk. IN A

;; ANSWER SECTION:
danisrael.vm.bytemark.co.uk. 86400 IN A 80.68.88.120

**********************************************************

; <<>> DiG 9.3.3rc2 <<>> therichmondstudio.co.uk
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 36335
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;therichmondstudio.co.uk. IN A

;; ANSWER SECTION:
therichmondstudio.co.uk. 86400 IN A 80.68.88.120

***********************************************************
Promextheus Xex [ Mo, 13 August 2007 17:48 ] [ ID #1793882 ]

Re: Virtual hosts not working

Post removed (X-No-Archive: yes)
Notifier Deamon [ Mo, 13 August 2007 18:07 ] [ ID #1793883 ]

Re: Virtual hosts not working

Davide Bianchi wrote:
> On 2007-08-13, zaphod <abc [at] def.com> wrote:
>> I've configured Apache with virtual hosting to run 3 domains, 2 pointing to:
>>
>> /var/www/html/danny
>>
>> .... and the 3rd pointing to:
>>
>> /var/www/html/richmond
>
> Are you sure that the directory /richmond contains a different html than
> the other two? From what you said and what I can see, the vhost works
> fine but the html returned is not the right one.
>
> The configuration looks correct.
>
> What does an apachectl configtest resturns? Have you restarted your
> apache service?
>
> Davide
>

httpd -S output:

VirtualHost configuration:
80.68.88.120:80 is a NameVirtualHost
default server dannyisrael.com (/etc/httpd/conf/httpd.conf:998)
port 80 namevhost dannyisrael.com (/etc/httpd/conf/httpd.conf:998)
port 80 namevhost dannyisrael.co.uk (/etc/httpd/conf/httpd.conf:1004)
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server www.therichmondstudio.co.uk
(/etc/httpd/conf/httpd.conf:1742)
port 80 namevhost www.therichmondstudio.co.uk
(/etc/httpd/conf/httpd.conf:1742)
port 80 namevhost www.dannyisrael.com
(/etc/httpd/conf/httpd.conf:1748)
port 80 namevhost www.dannyisrael.co.uk
(/etc/httpd/conf/httpd.conf:1754)
Syntax OK


Yes, the 2 directories have entirely different content. Both have distinct
index.html files.

Both directories and the files within them are owned by an ordinary user -
danny and permissions are standard 644 for files, 755 for directories.

I'm stumped :-(

Garry
Promextheus Xex [ Mo, 13 August 2007 19:07 ] [ ID #1793888 ]

Re: Virtual hosts not working

Post removed (X-No-Archive: yes)
Notifier Deamon [ Mo, 13 August 2007 19:27 ] [ ID #1793890 ]

Re: Virtual hosts not working

Davide Bianchi wrote:
> On 2007-08-13, zaphod <abc [at] def.com> wrote:
>> httpd -S output:
>>
>> VirtualHost configuration:
>> 80.68.88.120:80 is a NameVirtualHost
>> default server dannyisrael.com (/etc/httpd/conf/httpd.conf:998)
>> port 80 namevhost dannyisrael.com (/etc/httpd/conf/httpd.conf:998)
>> port 80 namevhost dannyisrael.co.uk (/etc/httpd/conf/httpd.conf:1004)
>> wildcard NameVirtualHosts and _default_ servers:
>> *:80 is a NameVirtualHost
>> default server www.therichmondstudio.co.uk
>
> Wait a minute... you have both a *:80 and a 80.68.88.120:80 ?
> That's wrong. You need only one NameVirtualHost entry.
>
> Remove the *:80 and change your VirtualHost *:80 in the same
> 80.68.88.120:80 for 'therichmondstudio'.
>
> Davide
>

Thanks Davide, I discovered I'd cut 'n pasted a duplicate of the
VirtualHosts section :-(

Garry
Promextheus Xex [ Mo, 13 August 2007 22:58 ] [ ID #1793893 ]
Webserver » alt.apache.configuration » Virtual hosts not working

Vorheriges Thema: default under domain
Nächstes Thema: Tracking a response