wampserver多站点配置

1,打开C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf

2,你会看到如下代码


# Virtual Hosts
#
# Required modules: mod_log_config

# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# 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 "c:/Apache24/docs/dummy-host.example.com"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "logs/dummy-host.example.com-error.log"
    CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
    ServerName dummy-host2.example.com
    ErrorLog "logs/dummy-host2.example.com-error.log"
<pre name="code" class="cpp">    CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
 复制最后一个标签 

修改成如下

<VirtualHost *:80>
    DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"  //这个地址修改成你自己的WWW目录下的新站点文件夹
    ServerName dummy-host2.example.com //这个是域名,随便改成你想要的
</VirtualHost>
3,打开保存

4,打开httpd.conf来让httpd-vhost.conf生效

5,在httpd,conf中查找“httpd-vhosts”

可以看到这段:

# Virtual hosts
# Include conf/extra/httpd-vhosts.conf


将include 前面的注释#去掉


注意:这里分为两种情况,一种为笔者自己新遇到解决的,网上没查到,另一种是网上可以查到的。

(这里可以解决服务器禁止的访问的问题)

第一种:(这是笔者遇到的情况)

找到一下内容:(可以通过查找directi)


<Directory />
    AllowOverride all
    Require all denied
</Directory>

将denied 修改为granted


第二种:

找到一下内容:

<Directory "f:/demo/">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride all

    #
    # Controls who can get stuff from this server.
    #

#   onlineoffline tag - don't remove
    Require local
    Order Deny,Allow
    Deny from alll
    Allow from 127.0.0.1
</Directory>


 

将Deny from all用#注释掉

将Allow from 127.0.0.1用#注释掉

下面添加一句  Allow from all

然后保存

6,就是在windows中的配置,可以让浏览器找到是本地的地址

打开 C:\Windows\System32\drivers\etc\hosts

在最后加入以下内容:

127.0.0.1  yourname.com //你刚才在httpd-vhosts.comf中创建的地址

然后保存。

7,重新打开wampserver,打开浏览器,输入你新建的地址,就可以进行测试了测试,别忘了在你得站点文件内写一个测试文件,不然不会有东西的.



    CustomLog "logs/dummy-host.example.com-access.log" common
    Require local
    Order Deny,Allow
    Deny from alll
    Allow from 127.0.0.1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值