gpt4 book ai didi

linux - Apache 服务器上的 403 错误

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:13:37 25 4
gpt4 key购买 nike

我将 Apache 的主目录“/var/www/html”更改为“/gwanwoonam/web”之后,Web 服务器返回 403 Error - Forbidden您无权访问此服务器上的/info.php。我该如何解决这个问题

我用谷歌搜索,找到了关于权限和 SELinux 的解决方案。我关闭了 SELinux,所以它被禁用了。

[gwanwoonam@localhost web]$ getenforce
Disabled

其次,我尝试编辑 conf 文件 sudo vim/etc/httpd/conf/httpd.conf

<Directory />
AllowOverride none
#Require all denied
Require all granted
Allow from all
</Directory>
...
DocumentRoot "/home/gwanwoonam/web"
...
<Directory "/home/gwanwoonam/web">
AllowOverride None
# Allow open access:
Require all granted
Allow from all
</Directory>
...
<Directory "/home/gwanwoonam/web">
#
# 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 Indexes FollowSymLinks

#
# 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 None

#
# Controls who can get stuff from this server.
#
Require all granted
Allow from all
</Directory>
...

并且,我把权限777放在了web目录,子文件夹和它的文件。

drwxrwxrwx. 2 gwanwoonam gwanwoonam   40 Jul 21 12:19 web
-rwxrwxrwx. 1 gwanwoonam gwanwoonam 106 Jul 21 11:52 index.html
-rwxrwxrwx. 1 gwanwoonam gwanwoonam 66 Jul 21 12:19 info.php

但是,我无法解决这个问题..我怎样才能找到解决方案?


日志

[Sun Jul 21 14:04:57.852935 2019] [core:error] [pid 1918] (13)Permission denied: [client ::1:51512] AH00035: access to /favicon.ico denied (filesystem path '/home/gwanwoonam/web') because search permissions are missing on a component of the path, referer: localhost 
[Sun Jul 21 14:05:00.422975 2019] [core:error] [pid 1923] (13)Permission denied: [client 127.0.0.1:42228] AH00035: access to / denied (filesystem path '/home/gwanwoonam/web') because search permissions are missing on a component of the path

最佳答案

在你的问题中你展示了这个:

drwxrwxrwx. 2 gwanwoonam gwanwoonam   40 Jul 21 12:19 web
-rwxrwxrwx. 1 gwanwoonam gwanwoonam 106 Jul 21 11:52 index.html
-rwxrwxrwx. 1 gwanwoonam gwanwoonam 66 Jul 21 12:19 info.php

请注意,index.htmlinfo.php web 目录下。因此 Apache 无法找到它们,因为您告诉它 DocumentRoot "/home/gwanwoonam/web"

将您的文件移动到 /home/gwanwoonam/web,然后 Apache 会看到它们。


然后,为确保您没有权限问题,在文件系统级别运行此命令:

chmod 755 /home/gwanwoonam/web
find /home/gwanwoonam/web -type d -exec chmod 755 {} \;
find /home/gwanwoonam/web -type f -exec chmod 644 {} \;

这将把权限 drwxr-xr-x 所有目录(包括 /home/gwanwoonam/web)和 -rw-r--r-- 在文件上。

这样你的 Apache 应该能够读取 web 下的所有文件,并将它们返回给你。

关于linux - Apache 服务器上的 403 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57136004/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com