Help setting up three or more domains from one ip

Support for webhosts that use CentOS
Post Reply
Molitov
Posts: 1
Joined: 2007/04/25 11:50:35

Help setting up three or more domains from one ip

Post by Molitov » 2007/04/25 12:03:08

hi all,

I have had this working before but can't remember how i did it :/
say i have 3 dyndns domains

domain1.dyndns.org
domain2.dyndns.org
domain3.dyndns.org
(For those that don't know, dyndns offers dynamic DNS Services)

here is what my virtualhosts.conf file is like:
[code]
<VirtualHost *>
ServerName domain1.dyndns.org
DocumentRoot /var/www/html/domain1
</VirtualHost>

<VirtualHost *>
ServerName domain2.dyndns.org
DocumentRoot /var/www/html/domain2
</VirtualHost>

<VirtualHost *>
ServerName domain3.dyndns.org
DocumentRoot /var/www/html/domain3
</VirtualHost>
[/code]
Now when i visit domain1.dyndns.org i get what i am supposed to get, the files in /var/www/html/domain1
but when i visit domain2 or domain3 .dyndns.org i still get the files from /var/www/html/domain1

Help please, has been driving me made for 2 days straight now...... :-(

Note: domain1, domain2, domain3 are not mine, i was using them for ease of understanding ^^ and have my proper ones in the config file naturally

foxb
Posts: 1924
Joined: 2006/04/20 19:03:33
Location: Montreal/QC

Help setting up three or more domains from one ip

Post by foxb » 2007/04/26 13:31:44

Read the notes in httpd.conf

from your output --> you frogot to specify the port.

mgreen
Posts: 2
Joined: 2007/04/29 19:17:08
Location: Wiltshire UK

Re: Help setting up three or more domains from one ip

Post by mgreen » 2007/04/30 12:14:40

Using non-IP Virtual Hosts
Using the new virtual hosts is quite easy, and superficially looks like the old method. The notable difference between IP-based and name-based virtual host configuration is the NameVirtualHost directive which specifies an IP address that should be used as a target for name-based virtual hosts.

For example, suppose that both www.domain.tld and www.otherdomain.tld point at the IP address 111.22.33.44. Then you simply add to one of the Apache configuration files (most likely httpd.conf or srm.conf) code similar to the following:

NameVirtualHost 111.22.33.44


ServerName www.domain.tld
DocumentRoot /www/domain



ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain


Of course, any additional directives can (and should) be placed into the section. To make this work, all that is needed is to make sure that the names www.domain.tld and www.otherdomain.tld are pointing to the IP address 111.22.33.44

Note: When you specify an IP address in a NameVirtualHost directive then requests to that IP address will only ever be served by matching s. The "main server" will never be served from the specified IP address. If you start to use virtual hosts you should stop to use the "main server" as an independent server and rather use it as a place for configuration directives that are common for all your virtual hosts. In other words, you should add a section for every server (hostname) you want to maintain on your server.

Post Reply

Return to “CentOS 5 - Webhosting Support”