You don't have permission to access

局域网内配置Discuz,web端访问server端,出现以下反馈:


 

Forbidden

You don't have permission to access / on this server.


网上的各种方法,主要集中于把

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow Deny from all Satisfy all </Directory>
改成
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow # Deny from all Allow from all #允许所有访问 Satisfy all </Directory>

以及把

<Directory "D:/Wamp5/www">

    #
    # 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.2/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: # Options FileInfo AuthConfig Limit # AllowOverride all # # Controls who can get stuff from this server. # # onlineoffline tag - don't remove Order Deny,Allow Deny from all Allow from 127.0.0.1 </Directory>
改成

<Directory "D:/Wamp5/www">

    #
    # 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.2/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: # Options FileInfo AuthConfig Limit # AllowOverride all # # Controls who can get stuff from this server. # # onlineoffline tag - don't remove Order Deny,Allow # Deny from all # Allow from 127.0.0.1 Allow from all </Directory>


 都没有效果。

 

从一位台湾省兄弟的博客(https://blog.longwin.com.tw/2014/03/apache-22-24-upgrade-conf-2014/)中看到,Apache2.2和2.4的设置方式是不一样的,总结如下:

 

    1. Deny All
      • 2.2 configuration:
        • Order deny,allow
        • Deny from all
      • 2.4 configuration:
        • Require all denied
    2. Allow All
      • 2.2 configuration:
        • Order allow,deny
        • Allow from all
      • 2.4 configuration:
        • Require all granted
    3. Allow HostDirectory 用 Require all granted
      • 2.2 configuration:
        • Order Deny,Allow
        • Deny from all
        • Allow from example.org
      • 2.4 configuration:
        • Require host example.org

    4. <Directory /var/>
      Options FollowSymLinks
      AllowOverride None
      Require all granted
      </Directory>

    5. FilesMatch 維持用 Order

      <FilesMatch ".+\.phps$">
      SetHandler application/x-httpd-php-source
      Order Deny,Allow
      Allow from all
      </FilesMatch>

 

也就是说,如果你用的是apache2.4,那么网上的那些方法基本上是没用的,得用新的设置方法。

 

然而,这些仍然没有解决我的问题。

 

走投无路的时候,翻到了conf/extra目录下的httpd-vhosts.conf,打开一看,内容如下:

 

<VirtualHost *:80>
ServerName localhost
DocumentRoot d:/wamp64/www
<Directory "d:/wamp64/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>

很可疑,改一下试试,改成:

<VirtualHost *:80>
ServerName localhost
DocumentRoot d:/wamp64/www
<Directory "d:/wamp64/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

重启apache,成功!

 

现得知,httpd.conf中有一个选项,

#Virtual hosts

#Include conf/extra/httpd-vhosts.conf 

用来指明是否使用额外的文件设置虚拟主机,这个选项在我这里默认是打开的:

#Virtual hosts

Include conf/extra/httpd-vhosts.conf 

所以,apache使用的是conf/extra/httpd-vhosts.conf 这个文件里的设置。

所以,无论怎样设置httpd.conf,都是无效的。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值