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的设置方式是不一样的,总结如下:
- Deny All
- 2.2 configuration:
- Order deny,allow
- Deny from all
- 2.4 configuration:
- Require all denied
- 2.2 configuration:
- Allow All
- 2.2 configuration:
- Order allow,deny
- Allow from all
- 2.4 configuration:
- Require all granted
- 2.2 configuration:
- 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
- 2.2 configuration:
<Directory /var/>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>- 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,都是无效的。