虚拟主机配置

1. 找到文件  C:\Windows\System32\drivers\etc\hosts
添加你的域名
127.0.0.1       localhost
127.0.1.1      tpshop.com
127.0.1.1      www.tpshop.com
2. 找到文件D:\wamp\bin\apache\apache2.4.9\conf\httpd.conf
# Virtual hosts
Include conf/extratpd-vhosts.conf   /到这一行,将#去掉 开启虚拟主机
3. 找到文件D:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-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
posted @ 2016-08-23 18:03  IT~民工  阅读(242)  评论(0编辑  收藏  举报