No matching directoryindex ошибка

The “Apache Error: No matching DirectoryIndex easily” error triggers due to missing of the particular index file from DirectoryIndex section in httpd.conf file.

As a part of our Server Management Services, we help our Customers to fix webserver related errors regularly.

Let us today discuss the possible causes and fixes for this error.

What is Apache Error: No matching DirectoryIndex?

The “No matching DirectoryIndex” error occur while accessing applications that have index files other than index.html or other specified ‘directory index’.

For example, phpMyAdmin includes an index.php file upon installation, but not an index.html file.

By default Apache is configured with the following:


DirectoryIndex index.html

Thus Apache will only look for directory index files that has name as index.html. As a result, when attempting to access phpMyAdmin, Apache throws the following error:

[autoindex:error] [pid 20115] [client 10.30.6.80:50800] AH01276: Cannot serve directory /usr/share/phpMyAdmin/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive

How to fix Apache Error: No matching DirectoryIndex?

The most common reason for this error is the missing of the particular index file from DirectoryIndex section in httpd.conf file. This can be easily fixed by editing the file. For instance, if it is to add index.php to add phpMyAdmin, it can be performed with the setof steps given below:

First step is to open the httpd.conf file with any of the available editors.

vim /etc/httpd/conf/httpd.conf

Now we need to identify the following set of lines in the configuration file.


DirectoryIndex index.html

Next task is to change it to the following format.


DirectoryIndex index.html index.php

Then save and exit the file. Finally, make sure to restart Apache with:

systemctl restart httpd

At times, this error can trigger when the PHP-FPM hits a limit of max allowed processes. We coulld fit it with an increase the value of max allowed processes. For example, in DirectAdmin servers, this can be set to 30 using the commands given below:

/usr/local/directadmin/directadmin set php_fpm_max_children_default 30
cd /usr/local/directadmin/custombuild/
./build rewrite_confs

In plesk environments, after a dist-upgrade, at time a 403 Forbidden is shown on all websites. The apache log shows the “No matching DirectoryIndex” in the apache error log.

To fix the error, enable the dir Apache module going to Tools & Settings > Apache Web Server > Select dir module > Click OK to apply changes

Note to include “IncludeOptional mods-enabled/*.conf” to the /etc/apache2/apache2.conf:

# grep "IncludeOptional mods-enabled/\*\.conf" /etc/apache2/apache2.conf
IncludeOptional mods-enabled/*.conf

[Need any further assistance in fixing Apache errors? – We’re available 24*7]

Conclusion

In short, The “No matching DirectoryIndex” error occur while accessing applications that have index files other than index.html or other specified ‘directory index’. Today, we saw how our Support Engineers fix this error.

It’s the first time I’m trying to deploy my Laravel App on my shared hosting account.

The folder structure is as follows:

|--laravel
  |--app
     |--GoPublic.php // use to point to new location 
  |--bootstrap
  |--config
  |--database
  // more folders 
|--public_html
  |--app // my subdomain document root
     |--assets
     |--index.php // GoPublic.php point to this file

When I go to my subdomain url, I get this:

enter image description here
I’ve checked my error.log file and I get the following 403 forbidden error:

[autoindex:error] [pid 910782] [] AH01276: Cannot serve directory /home/user/public_html/app/: No matching DirectoryIndex (index.php,Index.html,Index.htm,index.html.var,index.htm,index.html,index.shtml,index.xhtml,index.wml,index.perl,index.pl,index.plx,index.ppl,index.cgi,index.jsp,index.js,index.jp,index.php4,index.php3,index.phtml,default.htm,default.html,home.htm,index.php5,Default.html,Default.htm,home.html) found, and server-generated directory index forbidden by Options directive

Hope anyone can help me. Thanks!

How to Resolve the Apache Error: No matching DirectoryIndex?

Note

For this tutorial, you need to have root access and so, this can be done only on VPS, Dedicated and Cloud.

You might face this error while attempting to access applications that have an index.php file (or other index file), but not an index.html or other specified ‘directory index’ file.

For example, phpMyAdmin comprises of index.php file after installation, but not an index.html file.

Apache is by default configured with the below command:

DirectoryIndex index.html

It means that Apache will only check for the directory files that are named index.html.

While trying to access phpMyAdmin, Apache gives the below error:

[autoindex:error] [pid 20115] [client 10.30.6.80:50800] AH01276: Cannot serve directory /usr/share/phpMyAdmin/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive

In this case, add index.php to the DirectoryIndex directive.

vim /etc/httpd/conf/httpd.conf

Change the below line:

DirectoryIndex index.html

to:

DirectoryIndex index.html index.php

Now exit and save the file using the command :wq .

Ensure to restart Apache:

systemctl restart httpd

Congratulations! You have now learned to solve the Apache Error: No matching DirectoryIndex.

Also Read
Steps to Modify Apache Directory Listing Style
Learn to Restart Apache on Dedicated Server

This article will discuss about how to solve an error message as exist in the title of this article itself. Basically, the context of this article is troubleshooting to solve why a web-based application using Yii framework is not working. The actual error message exist as follows :

AH01276: Cannot serve directory /folder-path-root-web-location/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive

The error above exist after searching the cause in the error log file of Apache Webserver. It is because in the default root folder of the web-based application using Yii framework there is no file with the name of ‘index.html’ or ‘index.php’. Actually, there is a reason for Apache Webserver looking for the ‘index.html’ or ‘index.php’ file for initial execution of the web-based application. The reason is available in the Apache Webserver’s virtual host web-based application configuration. The configuration itself can exist in the main Apache Webserver’s file configuration. But it can also exist in other file configuration focusing on the virtual host definition. The following is the configuration lines for virtual host definition in order to inform Apache Webserver about how to access the web-based application :

<VirtualHost *:80>
ServerName localhost.webapps.web
ServerAdmin webmaster@localhost.webapps.web
DocumentRoot /var/www/html/webapps
    <Directory /var/www/html/webapps> 
             DirectoryIndex index.html index.php 
             Options -Indexes +FollowSymLinks +MultiViews AllowOverride All Require all granted 
    </Directory> 
ErrorLog /var/www/html/webapps/logs/localhost.webapps.web-error.log 
CustomLog /var/www/html/webapps/logs/localhost.webapps.web-access.log combined 
</VirtualHost>

As it is exist from the above line of configuration, there is a line as follows :

DirectoryIndex index.html index.php

The above line configuration means that index.html and index.php will be an index file in the root directory of the web-based application. So, the solution is simple. Just point of the root directory folder of the web-based application which contains the index.html or the index.php file. In the context of web-based application using Yii framework, it exist in the ‘web’ folder. So, change the DocumentRoot entry into the following line :

DocumentRoot /var/www/html/webapps/web

Make sure there is a file with the name of ‘index.html’ or ‘index.php’. Just check inside of the folder. Finally, don’t forget to restart the Apache Webserver’s service.

I installed phpmyadmin over a year ago.

I use MAC OS 10.10.4.
I don’t use Xampp.
My installation Folder is /Library/Webserver/Documents/phpmyadmin.

Now when I try to access phpmyadmin with that url, http://localhost/phpmyadmin/, i have:

403 Forbiden error You don’t have permission to access /phpmyadmin/ on this server.

in /var/log/apache2:

[Sat Oct 03 15:42:53.773654 2015] [autoindex:error] [pid 10682] [client 127.0.0.1:57694] AH01276: Cannot serve directory /Library/WebServer/Documents/phpmyadmin/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive

My question is how can i fix it and have an access to phpmyadmin again?

Ok, the answer of Rishi has solved the acces denied problem.

For the rest of the problem (index.php was downloaded but not executed), i had to (on httpd.conf):
Uncomment LoadModule php5_module libexec/apache2/libphp5.so
and add:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
AddType text/html .php (maybe the only one really necessary??)

see https://stackoverflow.com/questions/18422140/apache-is-downloading-php-files-instead-of-displaying-them

Community's user avatar

asked Oct 2, 2015 at 14:02

Sebastien Cavaignac's user avatar

0

Depending on your setup, you need to locate the correct .conf file (like apache-xampp.conf or httpd.conf or apache.conf or phpmyadmin.conf) in your web server installation directory for below lines and then Ctrl+F for phpmyadmin to find something like below:

<Directory /usr/share/phpmyadmin> ## The path here will vary depending on your setup and you don't have to change it
    Options FollowSymLinks
    DirectoryIndex index.php
    order deny,allow
    #deny from all
    allow from all

and change it to

<Directory /usr/share/phpmyadmin>
    Options Indexes FollowSymLinks MultiViews
    DirectoryIndex index.php
    AllowOverride all
    Require all granted

If you are going to access phpmyadmin from localhost only then you may use Allow from 127.0.0.1 instead of Require all granted above.

Restart apache service once you are done.

answered Oct 3, 2015 at 15:34

000's user avatar

5

Понравилась статья? Поделить с друзьями:
  • Noblelift pte15n коды ошибок
  • Nn dll vag can ошибка
  • No mans sky ошибка подключения здание
  • Noblelift ps16n коды ошибок
  • No label гарри поттер ошибка