您的位置:首页 > 其它

wamp环境下配置vhost

2016-05-14 11:48 561 查看
第一步:修改http.conf文件,将http-vhosts.conf配置文件包含进来

# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
改为
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
第二步:配置http-vhosts.conf

# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "D:\wamp\www"
ServerName localhost
ServerAlias www.dummy-host.example.com
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "F:\fast_rocket3"
ServerName rocket3.com
ErrorLog "logs/rocket3.com-error.log"
CustomLog "logs/rocket3.com-access.log" common
<Directory />
Require all granted
</Directory>
</VirtualHost>
http-vhost.conf文件中给了两个例子,我们只要在例子上稍微做些改动就可以:

在第一个例子中只改动了servername和documentRoot,这个配置保证了我们在开启vhost后仍然可以访问www目录。

在第二个例子中,除了修改serverName和documentRoot以外,还添加了Directory那句话,如果不添加这句话,当我们访问rocket3.com的时候会报403权限的错误。

第三步:修改C:\Windows\System32\drivers\etc\hosts文件

# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost

127.0.0.1       localhost
127.0.0.1       rocket3.com
最后一步:重启wamp
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: