如何在Apache Web服务器中启用目录列表

问题描述:

我无法在我的Apache Web服务器中启用目录列表.我已经尝试过发布各种解决方案,但是它不起作用.我刚刚重新安装了httpd 2.4.6,并在/etc/httpd/conf.d/ssl.conf 目录下使用 ssl.conf 启用了HTTPS,并尝试访问 https://server.example.com/,但这未列出目录.这些是文件 ssl.conf 中的配置:

I am not able to enable directory listing in my Apache web server. I have tried various solutions posted, but it is not working. I just freshly installed httpd 2.4.6 and enabled HTTPS using ssl.conf under the /etc/httpd/conf.d/ssl.conf directory and trying to access https://server.example.com/, but this is not listing the directory. These are the configuration in file ssl.conf:

DocumentRoot "/home/userx/Downloads/"
ServerName server.example.com:443

下面是VirtualHost元素下 ssl.conf 中的内容.安装文件时,文件和第一个 Directory 元素已经存在,并且我为"/home/userx/Downloads"添加了 Directory .访问URL /home/userx/Downloads 的内容> https://server.example.com/ .我在这里想念什么?

Below is what it has in ssl.conf under the VirtualHost element. Files and the first Directory elements were already there when I installed, and I just added Directory for "/home/userx/Downloads". I want to browse the contents of /home/userx/Downloads when I access the URL https://server.example.com/. What am I missing here?

<Files ~ "\.(cgi|shtml|phtml|php3?)$">
    SSLOptions +StdEnvVars
</Files>
<Directory "/var/www/cgi-bin">
    SSLOptions +StdEnvVars
</Directory>
<Directory "/home/userx/Downloads">
  Options +Indexes
  AllowOverride all
</Directory>

查看您是否能够访问/列出"/icons/"目录.这对于测试目录"的行为是有用的.在Apache中.

See if you are able to access/list the '/icons/' directory. This is useful to test the behavior of "Directory" in Apache.

例如:默认情况下,您的 httpd.conf 文件中可能具有以下配置.因此,点击URL IP:Port/icons/,看看它是否列出了图标.您也可以尝试将目录/文件夹"放在"var/www/icons"中.

For example: You might be having the below configuration by default in your httpd.conf file. So hit the URL IP:Port/icons/ and see if it lists the icons or not. You can also try by putting the 'directory/folder' inside the 'var/www/icons'.

Alias /icons/ "/var/www/icons/"

<Directory "/var/www/icons">
    Options Indexes MultiViews
    AllowOverride None
    Require all granted
</Directory>

如果确实有效,则可以使用<目录"//var/www/icons">进行交叉检查或修改自定义目录配置.配置.

If it does work, then you can cross-check or modify your custom directory configuration with the '<Directory "/var/www/icons">' configuration.