你没有';我无权访问此服务器上的/文件夹-AWS EC2


You don't have permission to access /folder on this server - AWS EC2

我知道有10亿个问题,但我无法让它发挥作用。

到目前为止我做了什么:

  1. 更改httd.conf文件,使DirectoryRoot为/home/ec2-user/folder

  2. 重新启动了我的apache服务器。

  3. chmod -R 775 /home/ec2-user/folder

  4. 更改了我的httd.conf(这里只有更改的行)

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
#DocumentRoot "/var/www/html"
DocumentRoot "/home/ec2-user/folder"

#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
#    Options FollowSymLinks
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
#    Allow from all
    Require all granted
</Directory>

然后这个:

# This should be changed to whatever you set DocumentRoot to.
#
#<Directory "/var/www/html">
<Directory "/home/ec2-user/folder">
#
# 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
    Options Indexes FollowSymLinks Includes ExecCGI
#
# 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.
#
    Order allow,deny
 #   Allow from all
Require all granted
</Directory>

然后这个:

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, in addition to the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
#
#Listen 12.34.56.78:80
#Listen 80
Listen 0.0.0.0:80

但我在/file.php.上的权限仍然被拒绝

我错过了什么?

编辑:我还更改了DocumentRoot。在此之前,我有一个错误的url错误,现在我没有权限。所以,现在,url是正确的,我只是没有为它设置正确的权限。

我没有做与上述不同的事情,但在重新启动Apache并多次退出AWS后,它神奇地起了作用。按照上面的步骤并检查日志中的错误,您应该已经修复了它。