1,修改本機(jī)的hosts文件,如下:
示例:
127.0.0.1 localhost
127.0.0.1 www.test.com
127.0.0.1 test.com
2,打開(kāi)Apache的安裝目錄,找到httpd.conf文件,分別去掉下面兩行文字前面的#號(hào)。
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
去掉#意思是啟用apache的虛擬主機(jī)功能?! ?br />
#Include conf/extra/httpd-vhosts.conf
去掉這一行的#意思是從conf/extra/httpd-vhosts.conf這個(gè)文件導(dǎo)入虛擬主機(jī)配置。
3,打開(kāi)extra目錄內(nèi)的httpd-vhosts.conf文件,把默認(rèn)的配置
ServerAdmin webmaster@dummy-host.localhost
DocumentRoot "/www/docs/dummy-host.localhost"
ServerName dummy-host.localhost
ServerAlias www.dummy-host.localhost
ErrorLog "logs/dummy-host.localhost-error_log"
CustomLog "logs/dummy-host.localhost-access_log common"
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"
改成自己想要的目錄和域名
ServerAdmin webmaster@dummy-host.localhost
DocumentRoot "D:/wamp/www/"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/localhost-error_log"
ServerAdmin webmaster@dummy-host.localhost
DocumentRoot "D:/wamp/www/web/"
ServerName test.com (填主域名)
ServerAlias *.test.com (這里的服務(wù)器別名可以支持泛解析)
ErrorLog "logs/localhost-error_log"
如果 弄完之后 出現(xiàn)403錯(cuò)誤 那 在httpd.conf里找到:
Options FollowSymLinks ExecCGI Indexes
AllowOverride None
Order deny,allow
Deny from all
Satisfy all
更改為
Options FollowSymLinks ExecCGI Indexes
AllowOverride None
# Order deny,allow
# Deny from all
# Satisfy all