1. 程式人生 > 其它 >Apach部署php應用報錯 Apache Error: No matching DirectoryIndex

Apach部署php應用報錯 Apache Error: No matching DirectoryIndex

Apache 錯誤的一個一般原因

  當嘗試訪問具有 index.php 檔案(或其他索引檔案)但沒有 index.html 或其他指定“目錄索引”檔案的應用程式時,可能會發生此錯誤。 例如,phpMyAdmin 在安裝時包含一個 index.php 檔案,但不包含一個 index.html 檔案。

預設情況下,Apache 配置如下:

<IfModule dir_module>
  DirectoryIndex index.html
</IfModule>

這意味著Apache只查詢名為index.html的索引檔案。

當部署php應用的時候,可能目錄下只有index.php檔案,Apache會報下面的錯誤:

[autoindex:error] [pid 2080] [client 192.168.137.1:6617] AH01276: Cannot serve directory /var/www/html/zentaopms/www/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive

這時,我們需要將index.php 新增到DirectoryIndex 指令下

修改配置檔案

vim /etc/httpd/conf/httpd.conf

新增index.php

<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>

儲存檔案並且重啟Apache伺服器

systemctl restart httpd

轉發地址:https://www.liquidweb.com/kb/apache-error-no-matching-directoryindex-index-html-found-solved/