Apache VirtualHost


Using Apache Virtual Host, you can run several websites on the same server.

There are two types of host
1) IP-Based Hosting
2) Name-based Hosting

Name-based virtual host is recommended and mostly used.

IP-Based
------------
In this we need to pointing two websites with two ip-address,so that the physical server should have two different ip-address configured.

Name-Based
-----------------
In name based,as the name specifies we dont need to worry about more ipaddresses.We can host many websites in a single ip-address.but,we need to update the DNS with multiple website names pointing to the same ip-address.

IP-Based Example
------------------------
Listen 80

<VirtualHost 76.75.111.200:80>
     DocumentRoot /var/www/example1
     ServerName www.example1.com
</VirtualHost>

<VirtualHost 76.75.111.201:80>
     DocumentRoot /var/www/example2
     ServerName www.example2.com
</VirtualHost>


Name-Based Example
----------------------------
Listen 80

NameVirtualHost 76.75.111.200:80           // name-based virtual hosts will be listening on port 80

<VirtualHost 76.75.111.201:80>
     ServerName www.example1.com
     DocumentRoot /var/www/example1
</VirtualHost>

<VirtualHost 76.75.111.201:80>
     ServerName www.example2.com
     DocumentRoot /var/www/example2
</VirtualHost>



Apache VirtualHost Apache VirtualHost Reviewed by vivek sathisan on 10:38 Rating: 5

No comments:

© Copyright to vivek sathisan. Powered by Blogger.