1、开启虚拟主机配置项(以apache为例)
#Include conf/extra/httpd-vhosts.conf
//把前面的#(注释去掉)开启
修改后需重启apache
2、设置文件httpd-vhosts.conf(confextra)
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:/wamp/www/renwu" (//文档根目录)
ServerName www.mytest.com (//主机地址)
</VirtualHost>
修改后需重启apache
3、配置hosts文件(c盘...etc目录下)
添加
127.0.0.1 www.mytest.com
注意把前面的#(注释去掉)