WAMPSever多站点配置
2016-09-04 本文已影响160人
WangJing6
1、首先找到安装目录下的wamp下bin下apache下apachexxx下conf下extra中的 httpd-vhosts.conf 文件(虚拟目录的配置文件),like this

2、打开 httpd-vhosts.conf 文件

3、复制两份以下代码,如下图所示

4、暂时我们只需要 DocumentRoot 和 ServerName ,为了避免干扰 我们暂时先删除必须要的代码

5、修改 DocumentRoot 和 ServerName ,然后保存

6、由于httpd-vhosts.conf 是作为一个扩展文件去加载的,默认是不会加载的,所以我们需要去告诉我们的Apache去包含这样一个配置文件,打开httpd.conf文件

按住Ctrl+F搜索 httpd-vhost

然后我们只需要将Include前面的#号去掉就行,#号的意思就是将这样代码注释掉,我们只需要去除#号就行了,然后保存

7、因为在Apache中是默认拒绝其他外部主机地址访问服务器下的资源,除了本地的,所以我们还需要修改成允许其他地址访问,所以我们再次打开Apache的配置文件

搜索 onlineoffline

将 Require local 注释掉,在前面加上#号

添加上 Require all granted

然后我们重启所有服务,配置完毕
8、在我们的Demo文件夹中新建我们的test01和test02文件夹

然后在test01和test02文件夹中分别新建index.php文件


分别输出 Hello,test01 和 Hello,test02


9、最后打开我们的hosts文件,"C:\Windows\System32\drivers\etc",将我们命名的test01.com和test02.com加入hosts,保存

10、验证是否成功,打开浏览器输入test01.com和test02.com,出线下图则表示配置成功

