# [Solved]Apache doesn't give directory listing

## jordanwb

When I go to a folder on my server that doesn't have an index file it gives an HTTP 404 error despite the fact that the folder exists. How do I configure Apache to display the directory listing instead of a 404? I'm running apache version 2.2.10Last edited by jordanwb on Sun Feb 01, 2009 7:52 pm; edited 1 time in total

----------

## VinzC

```
Options +Indexes

IndexOptions FancyIndexing NameWidth=60 FoldersFirst
```

The latter option enhances directory listing a little by giving 60 chars to display file names.

----------

## jordanwb

Well where do I put that?

----------

## VinzC

```
Options +Indexes

IndexOptions FancyIndexing NameWidth=60 FoldersFirst
```

 *jordanwb wrote:*   

> Well where do I put that?

 

In the configuration file that contains the definition for that folder. These options may appear inside a <VirtualHost>, <Directory> block or in a .htaccess file.

As far as I can see you need to read Apache documentation. You already have the documentation installed in /usr/share/doc/apache-2.2.10/ . If you browse http://localhost/manual you'll get it from your hard drive -- provided you emerged apache with USE flag doc. If you don't, check Apache documentation on the Internet.

----------

## jordanwb

This is what I have:

```
<IfDefine DEFAULT_VHOST>

        Listen 80

        NameVirtualHost *:80

        <VirtualHost *:80>

                ServerName localhost

                ServerAdmin root@localhost

                DocumentRoot "/var/www/localhost/htdocs"

                <Directory "/var/www/localhost/htdocs">

                        Options +Indexes FollowSymLinks

                        AllowOverride All

                        Order allow,deny

                        Allow from all

                </Directory>

                <IfModule alias_module>

                        ScriptAlias /cgi-bin/ "/var/www/localhost/cgi-bin/"

                </IfModule>

                <Directory "/var/www/localhost/cgi-bin">

                        AllowOverride None

                        Options None

                        Order allow,deny

                        Allow from all

                </Directory>

                <IfModule mpm_peruser_module>

                        ServerEnvironment apache apache

                </IfModule>

        </VirtualHost>

</IfDefine>

```

I put everything into /etc/apache2/httpd.conf because I didn't like having everything strewn accross a bunch of files. I put the + before Indexes but it still won't give the directory listing, see for yourself:

http://www.jordanwb.homelinux.com/folder/

----------

## gimpel

What does 

```
apache2ctl -q describe modules|grep autoindex
```

spit out?

Maybe you haven't set APACHE_MODULES in make.conf correctly.

----------

## jordanwb

 *gimpel wrote:*   

> What does 
> 
> ```
> apache2ctl -q describe modules|grep autoindex
> ```
> ...

 

Nothing.

 *gimpel wrote:*   

> Maybe you haven't set APACHE_MODULES in make.conf correctly.

 

Probably, when I installed apache a couple of months ago, I didn't know about that variable. When I emerged apache it said it wanted authz_host, dir, and mime so I set those. I'll add autoindex to the variable and recompile.

[Edit]

Nope, restarting apache still gives 404 for an empty folder.

[Edit #2]

Hold on a second.

I had to add this:

```
LoadModule autoindex_module modules/mod_autoindex.so
```

 to the section on modules in httpd.conf as well.

----------

## toralf

 *gimpel wrote:*   

> What does 
> 
> ```
> apache2ctl -q describe modules|grep autoindex
> ```
> ...

 

```
n22 /home/tfoerste # /usr/sbin/apache2ctl -q describe modules

 * ERROR: wrong args ( -q )

 * Usage: apache2 { configdump|configtest|fullstatus|graceful|gracefulstop|modules|reload }

 *        apache2 without arguments for full help

```

?

----------

## gimpel

 *toralf wrote:*   

>  *gimpel wrote:*   What does 
> 
> ```
> apache2ctl -q describe modules|grep autoindex
> ```
> ...

 

"-q" and "describe" should work with >=2.2.10

```
sirius ~ # apache2ctl -h

Usage: apache2 [options] stop | start | restart | describe | zap

Options: [dDsvChqv]

  -d, --debug                       set xtrace when running the script

  -s, --ifstarted                   only run commands when started

  -D, --nodeps                      ignore dependencies

  -h, --help                        Display this help output

  -C, --nocolor                     Disable color output

  -v, --verbose                     Run verbosely

  -q, --quiet                       Run quietly
```

But to see a list of loaded modules it's unneeded. Actually -q describe modules spits out the same as apache2ctl modules... I just complicated things up again.

----------

## toralf

I'm a little bit confused b/c of :

```
n22 ~ # cat /usr/sbin/apache2ctl

#!/bin/sh

exec /etc/init.d/apache2 "$@"

```

----------

## gimpel

 *toralf wrote:*   

> I'm a little bit confused b/c of :
> 
> ```
> n22 ~ # cat /usr/sbin/apache2ctl
> 
> ...

 

 :Shocked: 

Same here. I wasn't aware of that.

```
# /etc/init.d/apache2

Usage: apache2 [options] stop | start | restart | describe | zap

Options: [dDsvChqv]

  -d, --debug                       set xtrace when running the script

  -s, --ifstarted                   only run commands when started

  -D, --nodeps                      ignore dependencies

  -h, --help                        Display this help output

  -C, --nocolor                     Disable color output

  -v, --verbose                     Run verbosely

  -q, --quiet                       Run quietly
```

... which doesn't have that much to do with what is in the init script actually.

openrc-0.4.2 here, if that matters.

----------

## toralf

 *gimpel wrote:*   

> openrc-0.4.2 here, if that matters.

 oh yes

----------

