通常情况下,一个web服务代理一个网站,但是有时候我们需要用一台服务器代理多个网站。这个就是基于域名的虚拟主机技术。
我们可以直接在httpd.conf当中进行配置,也可以使用extra中的httpd-vhosts.conf配置,建议使用第二种方式。
首先要开启vhost.conf配置,
在httpd.conf文件中,找到Virtual hosts选项。启用httpd-vhosts.conf:
# Virtual hostsInclude conf/extra/httpd-vhosts.conf
然后在httpd-vhosts.conf中配置虚拟主机就行了:
NameVirtualHost *:80ServerName test.101.com DocumentRoot "D:\learn\PHPClass\php_ad_131016" Options Indexes order deny,allow allow from all
注意,在hosts文件里配置服务器域名和DNS
配置信息如下: