1,找到Apache下的httpd.conf文件,把虚拟主机开启。(如我的在:C:\wamp64\bin\apache\apache2.4.23\conf下)。
在httpd.conf文件中找到 #Include conf/extra/httpd-vhosts.conf这句话,将前面的#号去掉。
2,找到Apach下的httpd-vhosts.conf 一般是在apach安装目录下的conf目录下(如:C:\wamp64\bin\apache\apache2.4.23\conf\extra).
在httpd-vhosts.conf文件里添加如下代码
<VirtualHost *:80>
#网站根目录
DocumentRoot "F:/test"
#域名
ServerName www.test.com
#这里配置欢迎首页面
DirectoryIndex index.html index.htm index.php
<Directory />
Options FollowSymLinks
#不允许别人修改我们的页面
AllowOverride None
#设置访问权限
order allow,deny
Allow from all
</Directory>
3,Host文件是用于DNS解析,本地的host文件优于网络上的DNS解析。找到目录C:\Windows\System32\drivers\etc下的host文件,用记事本打开在后面添加一行 127.0.0.1 www.test.com。