Monday 15 April 2013

How to host multiple domains on the same http server using the same ip address

In Apache HTTP Server,we can use Name-based Virtual Hosts to host multiply domains on the same server using the same ip address. Using this method, you can have many different hosts sharing the same IP address. This method you need to configure your DNS server to map each hostname to the (same) IP address and set the Apache HTTP Server to recognize the different hostnames. This method of virtual hosting reduce the demand for IP addresses. Supposing you want to host 2 domains on 1 http server,you add the following to httpd.conf.

<virtualhost>
    # The first virtual host is also the default for *:80
    ServerName www.fc18.com
    ServerAlias fc18.com *.fc18.com
    DocumentRoot /var/www/html
</virtualhost>

<virtualhost>
    ServerName other.hosts.com
    ServerAlias hosts.com
    DocumentRoot /var/www/hosts
</virtualhost>

In the DNS server, you can add these to (bind) named.conf:

www.fc18.com.    A 192.168.0.16
fc18.com.        A 192.168.0.16
other.hosts.com. A 192.168.0.16
hosts.com.       A 192.168.0.16 
If you are using hosts file, you can add these to hosts file:

192.168.0.16 www.fc18.com
192.168.0.16 fc18.com
192.168.0.16 www1.fc18.com
192.168.0.16 other.hosts.com
192.168.0.16 hosts.com

No comments :

Post a Comment

search iomeweekly