How do you add directory listing to the php:7.2-apache image?

Hello Docker users!


Does somebody know how you can add directory listing to the php:7.2-apache image?
With directory listing I mean you get to see all the files and directories in a certain directory.


To run the image I use the following command:

podman run --rm --detach -p 8080:80 --name webserver -v ~/Webserver:/var/www/html:Z php:7.2-apache

The command works fine and the PHP files in the local direcory Webserver are generated correctly.


According to the Apache configuration inside of the container (see below), it should show the files and directories (Options Indexes) but somehow it doesn’t work?


Content of the file /etc/apache2/apache2.conf :

<Directory /var/www/>
	Options Indexes FollowSymLinks
	AllowOverride None
	Require all granted
</Directory>

Somebody know how I can ‘activate’ the directory listing?


Thanks for reading!


The indexes option for /var/www are overridden in

/etc/apache2/conf-enabled/docker-php.conf

Just remove the minus before Indexes in that file.

1 Like

Hello @meeuwdock,


Thank your very much: that did the trick!


The steps that I took:


Copy the configuration file to the host

podman cp [container id]:/etc/apache2/conf-available/docker-php.conf .

Open the file and remove the minus in front of Indexes.

vim docker-php.conf

Create Dockfile

vim Dockerfile

Content of the Dockerfile

FROM php:7.2-apache
COPY ./docker-php.conf /etc/apache2/conf-available/docker-php.conf

Create new image

podman build -t mywebserver .

Run the image

podman run --rm --detach -p 8080:80 --name webserver -v ~/Webserver:/var/www/html:Z mywebserver

Thanks!!