The term Virtual Host refers to the practice of running more than one web site (such as
www.linunix.in
and www.example.com
) on a single machine. Virtual hosts can be "IP-based", meaning that you have a different IP address for every web site, or "name-based", meaning that you have multiple names running on each IP address. The fact that they are running on the same physical server is not apparent to the end user.
Apache was one of the first servers to support IP-based virtual hosts right out of the box. Versions 1.1 and later of Apache support both IP-based and name-based virtual hosts (vhosts). The latter variant of virtual hosts is sometimes also called host-based or non-IP virtual hosts.
IP-BASED VIRTUAL HOST:
In this configuration, If we are pointing two websites (with different ip-address) to the server that runs Apache, that physical server should have two different ip-address configured.This means that the server should have two ethernet cards, each one of them configured to the ip-address of the corresponding website that Apache virtual host will be serving. So, this is not practical for most aspects, and you should not be using this.
NAME-BASED VIRTUAL HOSTS:
In this configuration, When Apache web server receives a request, it looks for the host name in the header, and depending on the hostname , it serves different websites.This is very easy and also you need only one ip address on that physical server but needs to update the DNS with multiple website names pointing to same ip address.
[root@linunix.in ~]# mkdir /var/www/linunix.in/index.html
[root@linunix.in ~]# mkdir /var/www/example.com/index.html
We need to mention the Apache
web server ip address on the below location.
[root@linunix.in ~]# vi
/etc/httpd/conf/httpd.conf
Search for NameVirtualHost and
uncomment this line by removing the # and add the IP to which
you want to receive Apache requests as below
Now, it’s time to setup Virtual
host sections for your domains, move to the bottom of the file by pressing Shift
+ G. Here in this example, we are setting up virtual host sections for two
domains
www.linunix.in & www.example.com
Add the following
two virtual directives at the bottom of the file. Save and close the file.
0 comments:
Post a Comment