1. 修改httpd.conf
去掉#Include conf/extra/httpd-vhosts.conf前面的#,启用虚拟主机功能
2.修改httpd-vhost.conf
在原有的
#<VirtualHost *:80>
# ServerName localhost
# DocumentRoot d:/wamp64/www
# <Directory "d:/wamp64/www/">
# Options +Indexes +Includes +FollowSymLinks +MultiViews
# AllowOverride All
# Require local
# Require all Granted
# </Directory>
#</VirtualHost>
# ServerName localhost
# DocumentRoot d:/wamp64/www
# <Directory "d:/wamp64/www/">
# Options +Indexes +Includes +FollowSymLinks +MultiViews
# AllowOverride All
# Require local
# Require all Granted
# </Directory>
#</VirtualHost>
注释掉,屏蔽WAMP安装后默认的虚拟主机文件目录,直接修改也行
3.增加新的虚拟主机配置,如下:
<VirtualHost *:80>
ServerName
www.icarbonasset.com
DocumentRoot d:/wamp64/www/carbon
<Directory "d:/wamp64/www/carbon">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
Require all Granted
</Directory>
</VirtualHost>
ServerName
DocumentRoot d:/wamp64/www/carbon
<Directory "d:/wamp64/www/carbon">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
Require all Granted
</Directory>
</VirtualHost>
4. 修改系统文件C:\Windows\System32\drivers\etc下的host文件,最后边增加两行:
127.0.0.1 localhost
127.0.0.1 www.icarbonasset.com
以上操作按照csdn博客http://blog.youkuaiyun.com/seafoodge/article/details/8660848。但是第4条的“127.0.0.1 localhost”注释掉不增加也可以,为什么博客里还提到要增加这一条?很奇怪。接下来,在httpd.conf上把“ServerName localhost:80”注释掉也可以本地访问127.0.0.1。
不太明白,估计是127.0.0.1是TCP/IP协议里默认的本机地址的原因?