wamp环境下配置vhost

第一步:修改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  block.
#

    ServerAdmin [email protected]
    DocumentRoot "D:\wamp\www"
    ServerName localhost
    ServerAlias www.dummy-host.example.com
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" common



    ServerAdmin [email protected]
    DocumentRoot "F:\fast_rocket3"
    ServerName rocket3.com
    ErrorLog "logs/rocket3.com-error.log"
    CustomLog "logs/rocket3.com-access.log" common
    
        Require all granted
    
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



你可能感兴趣的:(wamp环境下配置vhost)