/var/www/htmlの下の各ディレクトリに対してindex.htmlを生成する方法

/var/www/htmlの下の各ディレクトリに対してindex.htmlを生成する方法

/var/www/htmlディレクトリからアップグレードのために参加ソフトウェアをダウンロードしました。ディレクトリを一覧表示するには、各ディレクトリに対してindex.htmlを作成する必要があります。.htaccessディレクトリ内のファイルに以下を追加しようとしましたが(どこかで見たことがあり、index.htmlファイルがディレクトリに存在します)、うまくいきませんでした。

RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]

これを行うためのユーティリティやツールはありますか?誰かが手動で作成するように求めましたが、実際には手動で作成したくありません。

修正する

@Ipor Sircer/@Marcus Müller

ファイルを更新しましたhttpd.conf。これで、次のようになります。

# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/var/www/html"

#
# Relax access to content within /var/www.
#
<Directory "/var/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

# Further relax access to the default document root:
<Directory "/var/www/html">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options +Indexes +FollowSymLinks
    IndexOptions +FancyIndexing +HTMLTable

    #Options None

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    #AllowOverride None
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

この場所は次のとおりです/var/www/html

pwd
/var/www/html

drwxr-xr-x 5 root root  86 Nov  7 18:10 .
drwxr-xr-x 4 root root  33 Aug 12 15:33 ..
drwxr-xr-x 4 root root  46 Nov  6 13:35 clients
drwxr-xr-x 3 root root  55 Nov  6 19:52 packages.confluent.io
drwxr-xr-x 3 root root  17 Nov  6 15:57 rpm

しかし、サーバーに接続すると、次のような結果が出ます。

http://サーバー

そして、私が行くと、server/rpm次のようになります。

http://サーバー/rpm

/var/www/htmlブラウザで以下のディレクトリを表示するには、何を変更する必要がありますか?

ベストアンサー1

提案されているように、更新された設定と同様に使用@Ipor Sircerできます。FancyIndexing

<Directory "/var/www/html">
    Options +Indexes +FollowSymLinks
    IndexOptions +FancyIndexing +HTMLTable
</Directory>

このオプションの詳細をご覧ください。ここ。ただし、Apacheモジュールを有効にしないと機能しない可能性があります。

Apache設定でこのモジュールを有効にするには、コマンドを実行してからを使用mod_autoindexしてsudo a2enmod autoindexApacheを再起動しますsudo systemctl restart apache2。その後、現在の構成しなければならない必要に応じてディレクトリの内容を表示します。


修正する:私の間違いa2enmodダービズム。以下を使用してmod_autoindexRHELで有効にできます。

  1. sudo nano /etc/httpd/conf/httpd.conf
  2. 設定ファイルからLoadModuleさまざまなApacheモジュールをロードするためのガイドラインを含むセクションを見つけます。有効にするには、次の行を追加してくださいmod_autoindex
LoadModule autoindex_module modules/mod_autoindex.so
  1. 保存して終了しCTRL+xて確認してくださいy
  2. Apacheの再起動sudo systemctl restart httpd

それからmod_autoindex しなければならないシステムで有効にします。


アップデート2:以下の指示に従ってください。この投稿、ファイルを削除しwelcome.confてサービスを再起動することが含まれます。

おすすめ記事