Hosting multiple domains on the same server [DNS questions]

Support for webhosts that use CentOS
Post Reply
wminside
Posts: 3
Joined: 2009/11/30 23:49:30

Hosting multiple domains on the same server [DNS questions]

Post by wminside » 2010/02/13 14:54:39

Hi,

my question is pretty simple actually but haven't found a clear answer yet so...

Do I need a DNS server to host multiple domains on the same box?

I've always used Plesk and now I'm trying to do without it. So I have a bunch of questions but I'm testing everything on a virtual machine at home so this particular DNS stuff is giving me a hard time.

I would say that adding VirtualHost entries on my httpd.conf would be enough to support multiple domains.

[code]VirtualHost myip:80
DocumentRoot /www/mydomain1
ServerName mydomain1.com[/code]

[code]VirtualHost same_ip_as_before:80
DocumentRoot /www/mydomain2
ServerName mydomain2.com[/code]

[code]VirtualHost same_ip_as_before:80
DocumentRoot /www/mydomain3
ServerName mydomain3.com[/code]

But I haven't tested it yet on a regular box. Is this right? I so, why would someone need a DNS server?

I mean, most of my domains are on Enom.com so I use their nameservers. I just have to enter my servers' ips on the Host Records tab.

Maybe other registrars do not provide it?

I appreciate any helpful info :-)

guddibaaz
Posts: 6
Joined: 2010/02/12 16:12:13

Re: Hosting multiple domains on the same server [DNS questions]

Post by guddibaaz » 2010/02/13 18:43:37

DNS is used only to resolve host names to IP. As computers do not recognize host names they can only use IP to connect to other computers. So to Host multiple websites you do not need DNS only virtual host entry is enough. But how will any one from outside know what is the ip for the domains. For that DNS server is necessary. You can use DNS services of ISP or any other provider or you can setup your own DNS server but for that you need to register your DNS server from some Domain registrar. (POWER DNS)

hansolo
Posts: 231
Joined: 2010/01/13 11:17:42
Location: SI

Re: Hosting multiple domains on the same server [DNS questions]

Post by hansolo » 2010/02/16 21:03:15

[quote]
wminside wrote:

Do I need a DNS server to host multiple domains on the same box?

But I haven't tested it yet on a regular box. Is this right? I so, why would someone need a DNS server?
[/quote]
[b]In your case no[/b], because you wrote [quote]I mean, most of my domains are on Enom.com so I use their nameservers. I just have to enter my servers' ips on the Host Records tab.[/quote]
and
[quote]I would say that adding VirtualHost entries on my httpd.conf would be enough to support multiple domains.[/quote]
[b]you're right about this[/b] because you use DNS from your Enom provider.

Some quick guide of important things in httpd.conf [b]don't forget to replace 111.222.333.444 with your IP[/b]:
[code]Listen 80
ServerName 111.222.333.444

NameVirtualHost 111.222.333.444:80[/code]

and then Virtual Host configuration at the bottom:
[code]
<VirtualHost www.example.com:80 example.com:80>
ServerName www.example.com
DocumentRoot "/var/www/example.com/htdocs"
ScriptAlias /cgi-bin/ /var/www/example.com/cgi-bin/
# Alias /phpmyadmin/ /var/www/phpmyadmin/

<Directory />
Options -Indexes
AllowOverride All
Order Deny,Allow
Deny from all
</Directory>

<Directory "/var/www/example.com/htdocs">
Options -Indexes
AllowOverride All
Order allow,deny
Allow from all
</Directory>

<Directory "/var/www/example.com/cgi-bin">
Options -Indexes
AllowOverride All
Order allow,deny
Allow from all
</Directory>

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com$1 [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/
RewriteRule ^(.*)index\.html$ http://www.example.com$1 [R=301,L]

ErrorLog /var/log/httpd/error_log
#CustomLog /var/log/httpd/www.example.com_access_log combined env=!gif-image
#AddType text/html .shtml
#AddHandler server-parsed .shtml
</VirtualHost>
[/code]

Simply copy this and change [b]example.com[/b] with your domain names.
Should be working if you set DNS for domains to your IP.
[Moderator edit: added missing snippet at THE END of VirtualHost config.]

hansolo
Posts: 231
Joined: 2010/01/13 11:17:42
Location: SI

Re: Hosting multiple domains on the same server [DNS questions]

Post by hansolo » 2010/02/17 19:53:18

[b]I'm sorry, I forgot to copy the whole VirtualHost
and is missing THE END[/b]

so here it is:

[code]ErrorLog /var/log/httpd/error_log
#CustomLog /var/log/httpd/www.example.com_access_log combined env=!gif-image
#AddType text/html .shtml
#AddHandler server-parsed .shtml
</VirtualHost>[/code]

pschaff
Retired Moderator
Posts: 18276
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America
Contact:

Hosting multiple domains on the same server [DNS questions]

Post by pschaff » 2010/02/17 20:17:17

Patched it into post #3 - thanks.

robin339
Posts: 18
Joined: 2011/11/11 02:24:18

Re: Hosting multiple domains on the same server [DNS questions]

Post by robin339 » 2011/12/18 01:59:12

How would I set username/password for each different domain?
Thanks

w3bservice
Posts: 29
Joined: 2008/04/20 21:01:10
Contact:

Re: Hosting multiple domains on the same server [DNS questions]

Post by w3bservice » 2011/12/18 06:31:18

For a complettsolution with dns,mail,apache aka use this
[url=http://www.ispconfig.org/ispconfig-3/download/]ISP-Config[/url]
and the Howto for
[url=http://www.howtoforge.com/perfect-server-centos-5.7-x86_64-ispconfig-3]The Perfectserver CentOS 6.0 with ISP-Config 3[/url]

This is a OpenSource-Solutione thrue Plesk and Confixx.

For Question you can mail me

Joerg :lol:

Post Reply

Return to “CentOS 5 - Webhosting Support”