【问题标题】:WampServer: 403 ForbiddenWampServer:403 禁止
【发布时间】:2018-02-02 11:08:17
【问题描述】:

突然间,我的本地 WampServer 虚拟主机无法正常工作。

我已向vhosts.confhosts 添加了一个新的虚拟主机。

当我在网络浏览器中加载该虚拟主机时,我收到403 Forbidden

vhosts.conf,我有:

<VirtualHost *:80>
    ServerName example.com.au
    ServerAlias example.com.au
    DocumentRoot "D:\Dropbox\WAMP\WWW\example.com.au"
    <Directory  "D:\Dropbox\WAMP\WWW\example.com.au">
        Options Indexes FollowSymLinks MultiViews
        Require all granted
    </Directory>
</VirtualHost>

httpd.conf 我有:

Listen 10.0.0.199:80 ::1
Listen [::0]:80

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

其中 10.0.0.199 是我电脑的 IP。

WampServer 在线。

WampServer 3.0.6 阿帕奇 2.4.23

帮助表示赞赏。

【问题讨论】:

    标签: apache wampserver


    【解决方案1】:

    我变了

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

    <Directory />
        AllowOverride none
        Require all granted
    </Directory>
    

    httpd.conf 中,解决了 403 错误。

    【讨论】:

    • NOOOooooooo 千万不要这样做!在提出不好的建议之前,请查看 httpd.conf 文件的该部分的用途
    【解决方案2】:

    httpd.conf 中的默认配置具有您需要的所有 Listen 参数

    Listen 0.0.0.0:80
    Listen [::0]:80
    

    这表示在此 PC 的 IP 地址的端口 80 上侦听 IPV4 和 IPV6 地址范围,这就是您所需要的。

    httpd.conf 的这一部分也应该保留原样。这设置了对您安装 WAMPServer(Apache) 的驱动器上所有文件夹的所有权限的基本拒绝,并且应该这样做。改回这个

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

    这是为了您的安全。它说没有人被允许访问这个驱动程序的根目录,因此不能访问根目录下的任何东西。一旦设置好,您就应该只打开对 Apache 实际需要访问的内容的访问权限。这就是您在 httpd-vhosts.conf 文件中仅针对该站点也需要访问的文件夹所做的操作。 如果你被黑了,那么黑客只能访问那些被授予访问权限的文件夹,而不是你的整个驱动器。

    httpd-vhosts.conf 中的虚拟主机定义应如下所示

    <VirtualHost *:80>
        ServerName example.com.au
        ServerAlias www.example.com.au
        DocumentRoot D:/Dropbox/WAMP/WWW/example.com.au
        <Directory  "D:/Dropbox/WAMP/WWW/example.com.au/">
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
    
            ## Dangerous unless you really mean to 
            ## allow the universe into your server
            ## I would use one of the other options and comment this one out
            Require all granted
    
            # If access from this PC only then us
            # i.e. you are a standalone developer
            # uncomment this
            #Require local
    
            #If access from your local network is required
            # i.e. you are working with other devs within your local network
            # uncomment this
            #Require ip 10.0.0
    
        </Directory>
    </VirtualHost>
    

    注意 Unix 正斜杠的使用,&lt;Directory.... 标记需要尾部斜杠

    然后检查你的 HOSTS 文件应该是这样的

    127.0.0.1 localhost
    ::1 localhost
    127.0.0.1 example.com.au
    ::1 example.com.au
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-03
      • 2020-07-11
      • 1970-01-01
      • 2016-12-04
      • 1970-01-01
      • 2015-11-18
      • 2019-08-24
      • 2013-02-09
      相关资源
      最近更新 更多