wamp5虛擬主機的配置

1  編輯httpd.conf,查找Include conf/extra/httpd-vhosts.conf,把前面註釋符號“#”刪掉。
2  編輯httpd-vhosts.conf,我把WAMPServer安裝在D:/wamp,所以我這裏的路徑是D:\wamp\Apache2\conf\extra。 

把裏面的內容清空掉,換成下面的內容:

NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.host1.com
ServerAlias www.host1.com
DocumentRoot "D:/wamp/www/host1"
</VirtualHost>
<VirtualHost *:80>
ServerName www.host2.com
ServerAlias www.host2.com
DocumentRoot "D:/wamp/www/host2"
</VirtualHost>

3 編輯httpd.conf,找到DocumentRoot "d:/wamp/www/"這項,這是默認根目錄路徑,但是要更改的不是這個,一直往下找,找到<Directory "d:/wamp/www">,然後在該</Directoory>後加上如下內容:

<Directory "d:/wamp/www/host1">

Options Indexes FollowSymLinks

AllowOverride all
Order Allow,Deny
Allow from all
</Directory>

<Directory "d:/wamp/www/host2">
Options Indexes FollowSymLinks
AllowOverride all
Order Allow,Deny
Allow from all
</Directory>

4  修改C:/WINDOWS/system3/drivers/etc/host這個文件,用記事本打開,加上如下內容:
127.0.0.1  www.host1.com
127.0.0.1  www.host2.com

好了,然後重啓apache,在瀏覽器裏面輸入www.host1.com,看看訪問到的內容是不是host1這個目錄呢。

 

 

丸子:

<VirtualHost *:80>
DocumentRoot D:/wamp/www/test
ServerName www.test.com
</VirtualHost>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章