[英]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.php
和index.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/htdocs
, sudo 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.