1. 找到文件 C:WindowsSystem32driversetchosts
添加你的域名
添加你的域名
127.0.0.1 localhost 127.0.1.1 tpshop.com 127.0.1.1 www.tpshop.com
# Virtual hosts Include conf/extratpd-vhosts.conf /到这一行,将#去掉 开启虚拟主机
添加两个指向
<VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com DocumentRoot "D:/wamp/www" ServerName localhost ErrorLog "logs/dummy-host2.example.com-error.log" CustomLog "logs/dummy-host2.example.com-access.log" common </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com DocumentRoot "D:/wamp/wwwshop" ServerName tpshop.com ServerAlias www.tpshop.com ErrorLog "logs/dummy-host2.example.com-error.log" CustomLog "logs/dummy-host2.example.com-access.log" common </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com DocumentRoot "D:/wamp/www" ServerName 192.168.10.58 ErrorLog "logs/dummy-host2.example.com-error.log" CustomLog "logs/dummy-host2.example.com-access.log" common </VirtualHost>
4.若配置虚拟主机后,其他项目无法访问,需在httpd.conf文件中注释掉下面这行代码
#ServerName localhost:80