【发布时间】:2014-09-24 22:20:25
【问题描述】:
我知道有十亿个问题,但我无法让它发挥作用。
到目前为止我做了什么:
更改我的 httd.conf 文件,使 DirectoryRoot 为
/home/ec2-user/folder。重新启动我的 apache 服务器。
chmod -R 775 /home/ec2-user/folder更改了我的 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 错误,现在我没有权限。所以,现在,网址是正确的,只是我没有为它设置正确的权限。
【问题讨论】:
-
您的 conf 文件中设置的 APACHE_RUN_USER 和 APACHE_RUN_GROUP 是什么以及 DirectoryRoot 中文件的用户和组。
-
由于您的目录根目录已经包含
folder,该文件应该可以通过/file.php访问,而不是/folder/file.php。 -
@DavidLevesque 也试过了,同样的错误。
-
注意:
# This should be changed to whatever you set DocumentRoot to.... 你也设置了 DocumentRoot 吗? -
@Michael-sqlbot 是的,我做到了,抱歉忘了粘贴那个。在同一个文件中。在此之前它说找不到 url,现在它说我没有权限。所以,在我看来,这是一个权限问题——而不是一个错误的 url
标签: php apache amazon-web-services amazon-ec2