Apache—您不需要';我没有访问/访问此服务器的权限
在Apache—您不需要';我没有访问/访问此服务器的权限,apache,macos-sierra,Apache,Macos Sierra,在clg.localhost/中,我得到了一个错误: 您没有访问/访问此服务器的权限 但是,接下来,我设置了我的Apachehttpd.conf和sites.conf以允许使用AllowOverride all和Require all被授予的访问权限。我还缺什么 版本: $ /usr/sbin/httpd -v Server version: Apache/2.4.23 (Unix) Server built: Aug 8 2016 18:10:45 Apache httpd.conf:
clg.localhost/
中,我得到了一个错误:
您没有访问/访问此服务器的权限
但是,接下来,我设置了我的Apachehttpd.conf
和sites.conf
以允许使用AllowOverride all
和Require all被授予的访问权限。我还缺什么
版本:
$ /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>
/是一个目录,因此如果您没有使用DirectoryIndex指向的索引文件,例如index.html,并且没有启用索引,则Apache无法显示documentroot的内容
注意,您有以下选项:链接多视图
解决方案是,在选项中添加如下“目录列表”索引(这取决于之前加载的mod_autoindex):
如果要加载默认文件,例如index.html,DirectoryIndex默认会查找index.html,因此请添加它,或者如果某个文件在其他地方覆盖了它的行为,则执行以下操作:
DirectoryIndex index.html
检查/Users/danniu/Sites/CLG/CLG dev
的根目录中是否有与默认文档类型匹配的文件,如index.html
,default.htm
,并检查您是否没有从apache配置中删除该设置。@krangprime它是index.php
。但它应该仍然会拾取索引
,对吗?如果不是,如何将其指定为php文件?你说的是apache配置中的哪个设置?apache配置中的设置是DirectoryIndex
。例如:DirectoryIndex.php default.php index.htm default.htm index.html default.html index.phps
。至于运行一个php文件,请检查它是否可以显示普通的html文件。我假设您已经安装了php,并且模块链接/加载正确。检查文件系统权限,运行httpd进程的用户是否具有/Users/danniu/Sites/CLG/CLG dev
的读取权限?
<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>
Options FollowSymLinks Multiviews Indexes
DirectoryIndex index.html