Apache - 您无权访问/在此服务器上
Apache - You don't have permission to access / on this server
在 clg.localhost/
我收到错误:
You don't have permission to access / on this server.
但是,在 this 之后,我设置了我的 Apache httpd.conf
和 sites.conf
以允许使用 AllowOverride all
和 Require all granted
进行访问。我还缺少什么?
版本:
$ /usr/sbin/httpd -v
Server version: Apache/2.4.23 (Unix)
Server built: Aug 8 2016 18:10:45
Apache httpd.conf:
DocumentRoot "/Users/danniu/Sites"
<Directory "/Users/danniu/Sites">
#
# 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 FollowSymLinks Multiviews
MultiviewsMatch Any
#
# 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.
#
Require all granted
</Directory>
...
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride all
Require all granted
</Directory>
Apache sites.conf:
# Workaround for missing Authorization header under CGI/FastCGI Apache:
<IfModule setenvif_module>
SetEnvIf Authorization .+ HTTP_AUTHORIZATION=[=12=]
</IfModule>
# Serve ~/Sites at http://localhost
ServerName localhost
<VirtualHost *:80>
ServerName clg.localhost
DocumentRoot /Users/danniu/Sites/CLG/CLG-dev
</VirtualHost>
我想也许 httpd.conf
没有被正确提取,所以我直接在虚拟主机中指定了 root,但出现了同样的问题。
<VirtualHost *:80>
ServerName clg.localhost
DocumentRoot /Users/danniu/Sites/CLG/CLG-dev
# Set access permission
<Directory "/Users/danniu/Sites/CLG/CLG-dev">
Require all granted
</Directory>
</VirtualHost>
/ 是一个目录,所以如果你没有用 DirectoryIndex 指向的索引文件,比如 index.html,并且你没有启用 Indexes,因为你没有,Apache 可以'显示您的文档根目录的内容。
注意你有 Options FollowSymLinks Multiviews
解决方案,在选项中为 "directory listing" 添加如下索引(这取决于之前加载的 mod_autoindex):
Options FollowSymLinks Multiviews Indexes
如果您想要加载默认文件,例如 index.html,默认情况下 DirectoryIndex 会查找 index.html,因此添加它,或者如果它在其他地方覆盖了它的行为:
DirectoryIndex index.html
在 clg.localhost/
我收到错误:
You don't have permission to access / on this server.
但是,在 this 之后,我设置了我的 Apache httpd.conf
和 sites.conf
以允许使用 AllowOverride all
和 Require all granted
进行访问。我还缺少什么?
版本:
$ /usr/sbin/httpd -v
Server version: Apache/2.4.23 (Unix)
Server built: Aug 8 2016 18:10:45
Apache httpd.conf:
DocumentRoot "/Users/danniu/Sites"
<Directory "/Users/danniu/Sites">
#
# 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 FollowSymLinks Multiviews
MultiviewsMatch Any
#
# 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.
#
Require all granted
</Directory>
...
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride all
Require all granted
</Directory>
Apache sites.conf:
# Workaround for missing Authorization header under CGI/FastCGI Apache:
<IfModule setenvif_module>
SetEnvIf Authorization .+ HTTP_AUTHORIZATION=[=12=]
</IfModule>
# Serve ~/Sites at http://localhost
ServerName localhost
<VirtualHost *:80>
ServerName clg.localhost
DocumentRoot /Users/danniu/Sites/CLG/CLG-dev
</VirtualHost>
我想也许 httpd.conf
没有被正确提取,所以我直接在虚拟主机中指定了 root,但出现了同样的问题。
<VirtualHost *:80>
ServerName clg.localhost
DocumentRoot /Users/danniu/Sites/CLG/CLG-dev
# Set access permission
<Directory "/Users/danniu/Sites/CLG/CLG-dev">
Require all granted
</Directory>
</VirtualHost>
/ 是一个目录,所以如果你没有用 DirectoryIndex 指向的索引文件,比如 index.html,并且你没有启用 Indexes,因为你没有,Apache 可以'显示您的文档根目录的内容。
注意你有 Options FollowSymLinks Multiviews
解决方案,在选项中为 "directory listing" 添加如下索引(这取决于之前加载的 mod_autoindex):
Options FollowSymLinks Multiviews Indexes
如果您想要加载默认文件,例如 index.html,默认情况下 DirectoryIndex 会查找 index.html,因此添加它,或者如果它在其他地方覆盖了它的行为:
DirectoryIndex index.html