Forum Moderators: phranque

Message Too Old, No Replies

displaying the wrong website

         

mikel4u

6:46 pm on Jul 11, 2005 (gmt 0)

10+ Year Member



Hi guys I know this is a silly question but i don`t know what to do i have 2 sites in my server ( i just add the 2nd one) the DNS is working fine because when i ping the website2.com the dns resolves to mi server ip but when i type www.website2.com in a browser the browser displays the index page of website1.com i don't know where`s the misconfiguration i add the virtual host section of my httpd.conf file:

<VirtualHost x.x.x.x>
ServerName www.website1.com
DocumentRoot /var/apache/htdocs/website1/website1files
DirectoryIndex index.html
</VirtualHost>

<VirtualHost www.website2.com>
DocumentRoot "/var/apache/htdocs/website2/htmlfiles"
ServerName www.website2.com.
DirectoryIndex index.htm
</VirtualHost>

thanks in advances any guess will help.

Mikel

Romeo

7:23 pm on Jul 11, 2005 (gmt 0)

10+ Year Member



Hi Mikel,

therer are two valuable sources, when anything goes wrong or works unexpectedly:
-- the Apache docs
-- the error_log

In virtual hosting mode, whenever a request comes in and the httpd-server can't find a valid definition matching the request, it falls back to the default vhost definition, which is the first defined vhost in the config file.

In your 2nd definition, try a
<VirtualHost *:80>
The server's name does not belong here, as it is in ServerName line.
You don't have a dot(.) at the end of your ServerName in the first vhosts definition, so no need to have one in the second one.

Please, let us know if you get it to work.

Regards,
R.

mikel4u

10:55 pm on Jul 11, 2005 (gmt 0)

10+ Year Member



I did what you said Romeo, but i still get the website1 index page instead of the website2, so i don`t know what else can we try?

Thanks again.

Romeo

9:36 am on Jul 12, 2005 (gmt 0)

10+ Year Member



are there no hints is in the error_log
- during restart of the apache (you did restart?)
- when requesting website2?

Regards,
R.

mikel4u

2:22 pm on Jul 12, 2005 (gmt 0)

10+ Year Member



Hi, Romeo i check the error logs and all i have when i restart apache is this:

[Mon Jul 11 17:42:30 2005] [notice] caught SIGTERM, shutting down
[Mon Jul 11 17:42:43 2005] [notice] Apache/1.3.31 (Unix) configured -- resuming normal operations
[Mon Jul 11 17:42:43 2005] [notice] Accept mutex: fcntl (Default: fcntl)

and after the changes you told me this is the virtual host section of my httpd.conf:

<VirtualHost 10.1.1.5>
ServerName www.website1.com
DocumentRoot /var/apache/htdocs/website1/website1files
DirectoryIndex index.html
</VirtualHost>

<VirtualHost *:80>
ServerName www.website2.com
DocumentRoot "/var/apache/htdocs/website2/htmlfiles"
DirectoryIndex index.htm
</VirtualHost>

Thanks Again,

Mikel.

Romeo

10:54 am on Jul 13, 2005 (gmt 0)

10+ Year Member



Hi Mikel,

have you looked into the apache docs?
[httpd.apache.org...]

Try to eliminate the differences.
If the first vhosts definition works with a DocumentRoot without "quotes", I would define the second DocumentRoot definition likewise.
[actually I don't know if it works with quotes or not, but I know it works without.]

The doc has this example. If you follow it, everything should be fine then.

NameVirtualHost *

<VirtualHost *>
ServerName www.domain.tld
DocumentRoot /www/domain
</VirtualHost>

<VirtualHost *>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>

Although unrelated to your problem: your first <VirtualHost x.x.x.x> is only necessary with an explicit IP address if you have multiple IP addresses defined in your box and want the apache to specifically listen on exactly that one only. So a * (or *:80) could be fine on your first definition, too.

Regards,
R.

mikel4u

3:21 pm on Jul 14, 2005 (gmt 0)

10+ Year Member



I did it just like you said Romeo, and now i get an other error when i type www.website2.com:

"Forbidden/You don't have permission to access / on this server"

i search in the FAQ section for help and check what they said ( search for the string <Files ~>. and fix it, and the permissions for the directory) but everything is ok, so i'm asking you again for help.

Thanks for everything,

Any guess will help.

Mikel

Romeo

9:28 pm on Jul 14, 2005 (gmt 0)

10+ Year Member



Hi Mikel,

there may be several reasons for the webserver to send a "forbidden" (403?).

Did you check the error_log again?

Is the directory empty?
Perhaps you have configured the server not to show the directory content --> put an index page inside the document-root directory.

Regards,
R.