Thursday, February 17, 2005

Apache Virtual Host

The Virtual Host is one of these helpful but often overlooked feature.With the help of virtual host we can run more than one domain in a single host having one or more static IP. It will be helpful by two ways It will reduce server cost and it will make web desiging easier.
Why to create Virtual Host
Cost-effective:- Doing Virtual Host is cost-effective.We can use one machine with different names and doing different things. So, Instead of using more than one server for different purpose one server can do all the job.
Vhost Configuration
I have configured my computer for virtual hosts. i have added these lines in http.conf. As we know that as Apache starts it will read http.conf and it will create the virtual host.For creating virtual host i have given two DNS names to my computer.

1.somesite.com
2.somesubsidery.com

I have added these line in http.conf

NameVirtualHost somesite.com:80
NameVirtualHost somesubsidery.com:80

VirtualHost somesite.com
ServerAdmin somename@somesite.com
ServerName somesite.com
DocumentRoot /var/www/parent
Errorlog /etc/http/logs/error_log_parent
Accesslog /etc/http/logs/access_log_parent
VirtualHost

VirtualHost somesubsidery.com
ServerAdmin somename@somesubsidery.com
ServerName www.somesubsidiary.com
DocumentRoot /var/www/subsidiary
Errorlog /etc/http/logs/error_log_child
Accesslog /etc/http/logs/access_log_child
VirtualHost

As default port is 80. I have given same port number to my two virtual host.Then i added all the above things to my http.conf.I restarted my apache.Then it will setup virtual host for me.

No comments: