Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable a directory listing in Apache web server [closed]

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

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>
like image 698
Satish Burnwal Avatar asked Aug 31 '16 01:08

Satish Burnwal


People also ask

How do I check if directory browsing is enabled?

Under the "Actions" pane verify "Directory Browsing" is "Disabled". If "Directory Browsing" is not "Disabled", this is a finding. Follow the procedures below for each site hosted on the IIS 8.5 web server: Open the IIS 8.5 Manager.


3 Answers

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

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>

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

like image 79
Pnkj Avatar answered Oct 06 '22 10:10

Pnkj


According to the Apache documentation, found here, the DirectoryIndex directive needs to be specified in the site .conf file (typically found in /etc/apache2/sites-available on Linux).

Quoting from the documentation, it reads:

If no file from the DirectoryIndex directive can be located in the directory, then mod_autoindex can generate a listing of the directory contents. This is turned on and off using the Options directive. For example, to turn on directory listings for a particular directory, you can use:

<Directory /usr/local/apache2/htdocs/listme>
  Options +Indexes
</Directory>

To prevent directory listings (for security purposes, for example), you should remove the Indexes keyword from every Options directive in your configuration file. Or to prevent them only for a single directory, you can use:

<Directory /usr/local/apache2/htdocs/dontlistme>
  Options -Indexes
</Directory>
like image 12
MikeyE Avatar answered Oct 06 '22 11:10

MikeyE


Try this.

<Directory "/home/userx/Downloads">
  Options +Indexes
  AllowOverride all
  Order allow,deny 
  Allow from all 
  Require all granted
</Directory>

If that doesn't work, you probably have 'deny indexes' somewhere that's overriding your config.

like image 7
Eddimull Avatar answered Oct 06 '22 11:10

Eddimull