Virtual hosts not working

Virtual hosts not working

am 13.08.2007 17:48:45 von Promextheus Xex

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


ServerName www.therichmondstudio.co.uk
ServerAdmin garry@usableit.co.uk
DocumentRoot /var/www/html/richmond



ServerName www.dannyisrael.com
ServerAdmin garry@usableit.co.uk
DocumentRoot /var/www/html/danny



ServerName www.dannyisrael.co.uk
ServerAdmin garry@usableit.co.uk
DocumentRoot /var/www/html/danny



*********************************************************
; <<>> 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

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

Re: Virtual hosts not working

am 13.08.2007 18:07:16 von unknown

Post removed (X-No-Archive: yes)

Re: Virtual hosts not working

am 13.08.2007 19:07:11 von Promextheus Xex

Davide Bianchi wrote:
> On 2007-08-13, zaphod 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

Re: Virtual hosts not working

am 13.08.2007 19:27:00 von unknown

Post removed (X-No-Archive: yes)

Re: Virtual hosts not working

am 13.08.2007 22:58:02 von Promextheus Xex

Davide Bianchi wrote:
> On 2007-08-13, zaphod 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