Hosting multiple domains on the same server [DNS questions]

Support for webhosts that use CentOS

Hosting multiple domains on the same server [DNS questions]

Postby 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: Select all
VirtualHost myip:80
DocumentRoot /www/mydomain1
ServerName mydomain1.com


Code: Select all
VirtualHost same_ip_as_before:80
DocumentRoot /www/mydomain2
ServerName mydomain2.com


Code: Select all
VirtualHost same_ip_as_before:80
DocumentRoot /www/mydomain3
ServerName mydomain3.com


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 :-)
wminside
 
Posts: 3
Joined: 2009/11/30 23:49:30

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

Postby 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)
guddibaaz
 
Posts: 6
Joined: 2010/02/12 16:12:13

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

Postby hansolo » 2010/02/16 21:03:15

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?

In your case no, because you wrote
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.

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

you're right about this because you use DNS from your Enom provider.

Some quick guide of important things in httpd.conf don't forget to replace 111.222.333.444 with your IP:
Code: Select all
Listen 80
ServerName 111.222.333.444

NameVirtualHost 111.222.333.444:80


and then Virtual Host configuration at the bottom:
Code: Select all
<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>


Simply copy this and change example.com 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]

Postby hansolo » 2010/02/17 19:53:18

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


so here it is:

Code: Select all
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>
hansolo
 
Posts: 231
Joined: 2010/01/13 11:17:42
Location: SI

Hosting multiple domains on the same server [DNS questions]

Postby pschaff » 2010/02/17 20:17:17

Patched it into post #3 - thanks.
pschaff
Retired Moderator
 
Posts: 18277
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America

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

Postby robin339 » 2011/12/18 01:59:12

How would I set username/password for each different domain?
Thanks
robin339
 
Posts: 18
Joined: 2011/11/11 02:24:18

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

Postby w3bservice » 2011/12/18 06:31:18

For a complettsolution with dns,mail,apache aka use this
ISP-Config
and the Howto for
The Perfectserver CentOS 6.0 with ISP-Config 3

This is a OpenSource-Solutione thrue Plesk and Confixx.

For Question you can mail me

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


Return to CentOS 5 - Webhosting Support

Who is online

Users browsing this forum: No registered users and 1 guest