在clg.localhost/
我收到错误:
您无权访问此服务器上的内容。
但是,在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=$0
</IfModule>
# Serve ~/Sites at http://localhost
ServerName localhost
<VirtualHost *:80>
ServerName clg.localhost
DocumentRoot /Users/danniu/Sites/CLG/CLG-dev
</VirtualHost>
我想也许httpd.conf
没有被正确接收,所以我直接在虚拟主机中指定了根,但问题相同。
<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>
答案 0 :(得分:4)
/是一个目录,所以如果您没有指向DirectoryIndex的索引文件,例如index.html,并且您没有启用索引,那么您不需要, Apache无法显示您的文档内容。
请注意,您有Options FollowSymLinks Multiviews
解决方案,为选项添加索引,如下所示&#34;目录列表&#34; (这取决于先前加载的mod_autoindex):
Options FollowSymLinks Multiviews Indexes
如果你想加载一个默认文件,比如index.html,默认情况下DirectoryIndex会查找index.html,所以要添加它,或者如果它覆盖了其他地方的行为,那么:
DirectoryIndex index.html