1.打開Apache的配置文件httpd.conf,並去掉#Include conf/extra/httpd-vhosts.conf前面的#!!web
2.打開Apache的apache/conf/extra下的次配置文件httpd-vhosts.confapache
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文件的末尾添加上:
ide
<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文件中加上以下的內容spa
127.0.0.1 www.a.com
6.這樣咱們就配置好了名爲wamp的虛擬主機,重啓一下咱們在瀏覽器中輸入wamp就能夠查看到D:/wamp/www目錄下的內容了!!code
7.可是這樣localhost訪問則出現了問題,這時須要咱們,一樣將localhost設爲虛擬主機blog
<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,修改成allit