gpt4 book ai didi

linux - 访问某些 index.php 或 index.html 时出现 Apache 403 错误,尽管每个 index.php 或 index.html 具有相似的权限

转载 作者:太空宇宙 更新时间:2023-11-04 11:51:02 26 4
gpt4 key购买 nike

我的 Apache 服务器曾经可以正常工作,但它随机开始对几乎每个目录发出 403 错误。两个目录仍然有效,我怎样才能使/srv/www/htdocs 中的所有目录正常工作?

我查看了两个可用目录的权限,并将它们与未被访问的其他文件/文件夹进行了比较。两个工作目录是“BIBETIS”和“nextcloud”,而其他一切都不起作用。

BIBETIS下的index.php文件属于root用户,www组,权限为-rwxrwxr-x(我相信是755?)。该目录加载正常并按预期运行。

nextcloud 下的index.phpindex.html 文件属于用户wwwrun 和组www。它的权限再次是 -rwxrwxr-x。这一切都按预期运行。

因此,基于此,我尝试执行 sudo chown -R wwwrun:www/srv/www/htdocs, sudo chown -R wwwrun:www/srv/www/htdocs/*chmod -R 755/srv/www/htdocs/ 和类似变体。这并没有修复 apache 中的 403 错误。

我决定退后一步,专注于一个更简单的目录:“ map ”。该文件夹中有一个 index.html 文件。我再次尝试如上所述更改权限,但似乎无济于事。

apache 的错误日志如下:

[Fri May 10 01:39:35.665344 2019] [autoindex:error] [pid 2943] [client -:50203] AH01276: Cannot serve directory /srv/www/htdocs/map/: No matching DirectoryIndex (index.php4,index.php5,index.php) found, and server-generated directory index forbidden by Options directive
[Fri May 10 01:39:36.744342 2019] [autoindex:error] [pid 2943] [client -:50203] AH01276: Cannot serve directory /srv/www/htdocs/map/: No matching DirectoryIndex (index.php4,index.php5,index.php) found, and server-generated directory index forbidden by Options directive
[Fri May 10 01:39:42.323373 2019] [autoindex:error] [pid 2944] [client -:50204] AH01276: Cannot serve directory /srv/www/htdocs/map/: No matching DirectoryIndex (index.php4,index.php5,index.php) found, and server-generated directory index forbidden by Options directive
[Fri May 10 01:42:10.018496 2019] [autoindex:error] [pid 2038] [client -:50879] AH01276: Cannot serve directory /srv/www/htdocs/: No matching DirectoryIndex (index.php4,index.php5,index.php) found, and server-generated directory index forbidden by Options directive

是什么让我相信它只是在搜索 index.php 文件?所以我在 map 目录下设置了一个 index.php ,应用了正确的权限,它工作了。如果是这样,为什么即使设置了正确的 user:group 和 755 权限,它也无法访问位于 htdocs 目录中的主要 index.php

最佳答案

你能告诉我们你的虚拟主机和你的 apache.conf/httpd.conf 的配置吗?为了能够读取 index.html,您需要将指令添加到 DirectoryIndex index.html 中,否则您的 Web 服务器将不知道他需要读取它,它应该看起来像这样:

DirectoryIndex index.html index.php4 index.php5 index.php

如错误信息所示,它与文件/文件夹权限无关!

关于linux - 访问某些 index.php 或 index.html 时出现 Apache 403 错误,尽管每个 index.php 或 index.html 具有相似的权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56071552/

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