Dealing with index.php file without referencing other index files such as an index.html sometimes causes Apache error No matching DirectoryIndex.
Here at IbmiMedia, We have dealt with numerous Apache errors for our customers as part of our Server Support Services.
In this context, we shall look into why this error occurs and how to fix it.
More about Apache error: No matching DirectoryIndex
Most application require that the index.html or other specified directory file is accessible even when it has an index.php file.
If you have a look at Apache configuration file, index.html file is specified by default. Let us consider PhpMyAdmin for example. It does have an index.php file but does not include an index.html file when installed. Its Apache configuration file directive looks like;
What this signifies is that, Apache web server will only reference to index files having the index.html.
In this case, if you try to access the PhpMyadmin, the following error will be thrown;
[autoindex:error] [pid 20021] [client 184.108.40.206:60400] AH01276: Cannot serve directory /usr/share/phpMyAdmin/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive
The principal causes of this error are;
i. When dir module is not enabled such as in Plesks Control panel.
ii. Misconfiguration in Apache configuration file. This means that the index file is not referenced in the DirectoryIndex.
iii. The Limit of max allowed processes has been exceeded by PHP-FPM.
Let us see how to resolve this error.
How to solve Apache error: No matching DirectoryIndex
We can utilize different approaches when it comes to fixing this issue.
i. Adjusting Max allowed processes in PHP
Setting a higher value for max allowed processes can help fix this issue. For example, in DirectAdmin Control panel, you can increase the value for max allowed processes via the command below;
/usr/local/directadmin/directadmin set php_fpm_max_children_default 60
ii. Rectifying Apache DirectoryIndex configuration.
Including an index.php file to the DirectoryIndex directive can help to fix this issue.
You can add an index.php reference in the /etc/httpd/conf/httpd.conf which is Apache configuration file and then save it. After this, you can restart Apache via the command below;
systemctl restart httpd