Apache两种虚拟主机方式的区别

发表于:2007-06-08来源:作者:点击数: 标签:
大多数人可能就知道 Apache 的基于名字的虚拟主机,不知道 Apache 还可以有基于 IP 的虚拟主机。前者的道理不言自明,多个域名( 服务器 )对应一个 IP 地址,配置方法为: NameVirtualHost 111.22.33.44 ServerName www.sample.com DocumentRoot /www/sampl

大多数人可能就知道 Apache 的基于名字的虚拟主机,不知道 Apache 还可以有基于 IP 的虚拟主机。前者的道理不言自明,多个域名(服务器)对应一个 IP 地址,配置方法为:


NameVirtualHost 111.22.33.44


ServerName www.sample.com
DocumentRoot /www/sample


 


ServerName www.sample2.com
DocumentRoot /www/sample2



但是在有些 IP 地址充裕,但是机器资源紧张的环境下,我们可能要把多个域名解析到同一台机器上,其配置方法为:



ServerName www.smallco.com
DocumentRoot /groups/smallco/www


 


ServerName www.baygroup.org
DocumentRoot /groups/baygroup/www



这种方法下,要求机器配置多个 IP 地址。


(作者:徐永久)

原文转自:http://www.ltesting.net