现在先来配置虚拟主机:
1.先打开apache的配置文件httpd.conf,并去掉#Include
conf/extra/httpd-vhosts.conf前面的#!!
2.打开apache的apache/conf/extra下的次配置文件httpd-vhosts.conf
3.将此文件下的原有的扩展配置文件(如下):删除一个或两个
<VirtualHost
*:80>
ServerAdmin
webmaster@dummy-host2.localhost
DocumentRoot /www/docs/dummy-host2.localhost
ServerName dummy-host2.localhost
ErrorLog
logs/dummy-host2.localhost-error_log
CustomLog logs/dummy-host2.localhost-access_log
common
</VirtualHost>
4.在httpd-vhosts.conf文件的末尾添加上:
<VirtualHost *:80>
DocumentRoot D:/wamp/website/a.com
ServerName www.a.com
<Directory
"D:/wamp/website/a.com">
Options
Indexes FollowSymLinks
AllowOverride None
Order
allow,deny
Allow from all
</Directory>
</VirtualHost>
5.打开在C:/WINDOWS/system32/drivers/etc中的hosts文件中加上如下的内容
127.0.0.1 www.a.com
6.这样我们就配置好了名为wamp的虚拟主机,重启一下我们在浏览器中输入wamp就可以
查看到D:/wamp/www目录下的内容了!!
7.但是这样localhost访问则出现了问题,这时需要我们,同样将localhost设为虚拟主机
<VirtualHost *:80>
DocumentRoot
D:/wamp/www
ServerName localhost
<Directory "D:/wamp/www">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
8:为了让其他电脑用IP访问电脑,需要在httpd.conf 中搜索127.0.0.1 修改为all