1、修改 hosts 文件:
打开 C:\window\system32\drivers\etc\hosts 文件,添加一句:
127.0.0.1 www.tp.com
2、修改 apache 的配置文件 httpd.conf
首先打开 apache 的配置文件 httpd.conf,比如我的是在C:\wamp\bin\apache\apache2.4.9\conf文件夹下,找到这一行:
#Include conf/extra/httpd-vhosts.conf
去掉 “#”号
3、修改 httpd-vhosts.conf 文件
打开 C:\wamp\bin\apache\apache2.4.9\conf\extra 文件夹下的 httpd-vhosts.conf 文件,加上这么一段,例如:
<VirtualHost *:80>
DocumentRoot "F:\wamp\www\google"
ServerName www.google.com
ServerAlias google.com
</VirtualHost>
4、注意:
一定要把 第一组 中的 DocumentRoot " 改成网站根目录:C:/wamp/www"
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "C:/wamp/www"
ServerName 127.0.0.1:80
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
网友评论