ubuntu 13.10のApache 2.4に問題があります。 Document Rootを/ home/fandi/public_htmlに変更しようとしましたが、すべて正常に動作しています。しかし、私はpublic_htmlにフォルダを作成しようとしました/このようなエラーが発生します:
[Sat Jan 25 10:59:50.149441 2014] [autoindex:error] [pid 1093] [client 127.0.0.1:39901] AH01276: Cannot serve directory /home/fandi/public_html/report_php/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive
ファイルを作成する必要がありますindex.html
、index.php
およびその他のindex.xxx
ファイル。
デフォルトでは、ディレクトリインデックスを表示する必要があります。ディレクトリインデックスを有効にする方法
これは私のファイル000-default.conf
:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /home/fandi/public_html
ErrorLog ${Apache_LOG_DIR}/error.log
CustomLog ${Apache_LOG_DIR}/access.log combined
<Directory "/home/fandi/public_html">
Options All
AllowOverride All
Require all granted
Options Indexes FollowSymLinks
</Directory>
</VirtualHost>
# vim: syntax=Apache ts=4 sw=4 sts=4 sr noet
助けてください、ありがとう^^
自動インデックスを取得するには、Apache 2.4でDirectoryIndexを無効にする必要があることがわかりました。
DirectoryIndex disabled
Options Indexes
DirectoryIndexが無効になっていない場合、自動インデックスは機能せず、fastcgi/php-fpmを使用すると、Apacheは403 Forbiddenまたは404 File not foundを送信します。
対応するエラーログの行は次のとおりです(検索目的)。
[authz_core:error] client denied by server configuration:
[proxy_fcgi:error] Got error 'Primary script unknown\n'
Options All <--turn on all options
Options Indexes FollowSymLinks <--- replace previously set options with these two
2行目は冗長です。1行目ですべてのオプションをすでにオンにしているため、2つのオプションの先頭に+
が付いていないため、実際に有効なオプションリスト全体をAll
これら2つの個別オプションのみ。
私はそれを機能させることができました
基本的に、以前のバージョンのように仮想ホストがDocumentRootのサブフォルダーでない限り、Apache2.4はDocumentRootから仮想ホストに設定を引き継がないようです。どの種類が理にかなっていますが、変更は文書化されるべきであり、そうではありませんでした。
つまり、httpd.confに次のようになります(これはOS Xのものです)。
DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">
Options +Indexes +FollowSymLinks
# etc
</Directory>
そして、あなたのextra/httpd-vhosts.confで
<VirtualHost *:80>
DocumentRoot "/pth/to/somewhere/completely/different"
ServerName my-virtual-Host.dev
ErrorLog "/private/var/log/Apache2/my-virtual-Host.dev-error_log"
CustomLog "/private/var/log/Apache2/my-virtual-Host.dev-access_log" common
</VirtualHost>
VHはすべての設定を継承するために使用されていました-サブフォルダーではない場合はもうそうではありません。そのため、VHで設定をコピーして貼り付けます(または、別の<directory
同じ場所に多くのVHがある場合)
<VirtualHost *:80>
DocumentRoot "/pth/to/somewhere/completely/different"
ServerName my-virtual-Host.dev
ErrorLog "/private/var/log/Apache2/my-virtual-Host.dev-error_log"
CustomLog "/private/var/log/Apache2/my-virtual-Host.dev-access_log" common
<Directory "/pth/to/somewhere/completely/different">
Options +Indexes
</Directory>
</VirtualHost>
魔法をかけるのは+ Indexesです。
Centos 7.2とApache 2.4でも同じ問題が発生しました。
新規インストールでは、問題はおそらくwelcome.conf
すべての場所でオプションインデックスを無効にします。
<LocationMatch "^/+$">
Options -Indexes
ErrorDocument 403 /.noindex.html
</LocationMatch>
このファイルは、Apacheをアップグレードするたびに復元されるため、前の行をコメント化または削除する必要があります。
ログでエラーを見つけることができます
[Sun Dec 03 17:38:17.649269 2017] [autoindex:error] [pid 4806] [client :: 1:57323] AH01276:ディレクトリ/ etc/httpd/conf/htdocs /を提供できません:一致するDirectoryIndex()が見つかりません、およびOptionsディレクティブで禁止されているサーバー生成のディレクトリインデックス
それを修正するには:-
次に、/ etc/httpd/conf.d/welcome.confの行を削除する必要があります
既存の構成の下:-
<LocationMatch "^/+$">
Options -Indexes
ErrorDocument 403 /.noindex.html
</LocationMatch>
以下の設定で解決しました:-行をコメントアウトしました。
<LocationMatch "^/+$">
#Options -Indexes
ErrorDocument 403 /.noindex.html
</LocationMatch>
この行をサイトのvhost.confファイルに追加します
DirectoryIndex default.html
そして、あなたはすべて設定されています
将来の人々のために、上記のすべてを実行しても問題が引き続き発生する場合は、これを試してください:
httpd.conf(make sure belows are open):
LoadModule alias_module modules/mod_alias.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_Host_module modules/mod_authz_Host.so
LoadModule autoindex_module modules/mod_autoindex.so
Include conf/extra/httpd-autoindex.conf
extra/httpd-autoindex.conf:
<Directory "change to your directory">