简体   繁体   English

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

[英]Apache 403 error from accessing certain index.php or index.html despite having similar permissions for each

My apache server was once working, but randomly it started spitting out a 403 error for just about every directory. 我的apache服务器曾经工作过,但它随机地开始为几乎每个目录吐出403错误。 Two directories remain working, how can I get all directories within /srv/www/htdocs working correctly? 两个目录仍然有效,如何才能使/ srv / www / htdocs中的所有目录正常工作?

I have looked at the permissions for the two directories that work and compared them to other files/folders that aren't being accessed. 我查看了两个工作目录的权限,并将它们与未访问的其他文件/文件夹进行了比较。 The two working directories are "BIBETIS" and "nextcloud", while everything else does not work. 两个工作目录是“BIBETIS”和“nextcloud”,而其他一切都不起作用。

The index.php file under BIBETIS is owned by user root, and group www, its permissions are -rwxrwxr-x (I believe 755?). BIBETIS下的index.php文件由用户root和组www拥有,其权限是-rwxrwxr-x (我相信755?)。 This directory loads fine and functions as expected. 此目录加载正常并按预期运行。

The index.php and index.html file under nextcloud is owned by user wwwrun and group www. nextcloud下的index.phpindex.html文件由用户wwwrun和组www拥有。 Its permissions are -rwxrwxr-x once again. 它的权限再次是-rwxrwxr-x This all functions as expected. 这一切都按预期运作。

So, based off this I have tried doing sudo chown -R wwwrun:www /srv/www/htdocs , sudo chown -R wwwrun:www /srv/www/htdocs/* , chmod -R 755 /srv/www/htdocs/ and similar variations. 所以,基于此我尝试做sudo chown -R wwwrun:www /srv/www/htdocssudo chown -R wwwrun:www /srv/www/htdocs/*chmod -R 755 /srv/www/htdocs/和类似的变化。 This did not fix the 403 error in apache. 这没有修复apache中的403错误。

I decided to take a step back and focus on a single, more simple directory: "map". 我决定退后一步,专注于一个更简单的目录:“map”。 This folder has one index.html file. 此文件夹有一个index.html文件。 I once again tried changing the permissions as described above, yet nothing seems to help. 我再次尝试如上所述更改权限,但似乎没有任何帮助。

The error log for apache reads: 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 

Which led me to believe it is only searching for index.php files? 这让我相信它只搜索index.php文件? So I set up an index.php under the map directory, applied correct permissions, and it worked. 所以我在map目录下设置了一个index.php,应用了正确的权限,并且工作正常。 If so, why can it not access the main index.php located within the htdocs directory even after setting proper user:group and 755 permissions? 如果是这样,为什么即使在设置了正确的user:group和755权限之后它也无法访问位于htdocs目录中的主index.php

Can you show us the configuration of your vhost and your apache.conf/httpd.conf ? 你能告诉我们你的vhost和apache.conf / httpd.conf的配置吗? To be able to read the index.html you need to add to the directive DirectoryIndex index.html otherwise your web server won't know that he needs to read it, it should look something like this: 为了能够读取index.html,您需要添加到指令DirectoryIndex index.html,否则您的Web服务器将不知道他需要读取它,它应该看起来像这样:

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

As the error message shows clearly, it's not related to file/folder permissions! 由于错误消息显示清楚,它与文件/文件夹权限无关!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我只为 index.php 文件而不是 index.html 文件收到 403 禁止错误? (Apache2, debian11) - Why am i getting a 403 forbidden error only for index.php files not index.html ones? (Apache2, debian11) 从任何没有index.php的文件夹将用户路由到某个文件,例如:index.php | 使用.htaccess - Route user to some file like: index.php from any folder which is not having index.php | using .htaccess ERROR 403在我的index.php中加载CSS和JS等资源 - ERROR 403 in loading resources like CSS and JS in my index.php 阻止Nginx重定向到index.php - Stop nginx from redirecting to index.php 从.iso修改index.php - Modify a index.php from an .iso 安全吗? 覆盖 apache2 index.php 以确保安全 - Is it safe? Overwrite apache2 index.php for security 为什么 Apache 不允许从 index.html 中访问 web 根目录之外的文件? - Why doesn't Apache allow access to files outside the web root from within index.html? Apache on CentOS在配置路由到“ Index.html”(大写“ I”)时出现问题 - Apache on CentOS issue configuring routing to “Index.html” (uppercase“I”) Web浏览器不在htdocs目录中显示index.html - Apache - Web browser not displaying the index.html in the htdocs directory - Apache 在index.php / admin上使用Apache LDAP身份验证 - Using Apache LDAP Authentification on index.php/admin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM