简体   繁体   中英

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. Two directories remain working, how can I get all directories within /srv/www/htdocs working correctly?

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.

The index.php file under BIBETIS is owned by user root, and group www, its permissions are -rwxrwxr-x (I believe 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. Its permissions are -rwxrwxr-x once again. 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. This did not fix the 403 error in apache.

I decided to take a step back and focus on a single, more simple directory: "map". This folder has one index.html file. I once again tried changing the permissions as described above, yet nothing seems to help.

The error log for apache reads:

[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? So I set up an index.php under the map directory, applied correct permissions, and it worked. 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?

Can you show us the configuration of your vhost and your 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:

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

As the error message shows clearly, it's not related to file/folder permissions!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM