Displaying a listing of files in a directory
A web server makes a great repository for downloadable files. This system of file distribution has for the most part replaced anonymous FTP as it offers a more seamless experience for users. If you would like to give users access to a directory of files with an automatically generated index, Apache is the right tool for the job.
Note
In most cases, listing files in directories of a website is unnecessary, and in some cases it may even expose sensitive information to potential attackers. Use directory listings only where it makes sense.
Getting ready
In this recipe, we will expose a listing of the directory /var/www/example.com/downloads
, which is served by the virtual host named example.com
from the URL http://example.com/downloads
. Note the file path, virtual host name, and URL of your case and substitute appropriately.
How to do it...
Perform the following steps to display a listing of files in a directory:
Create the directory
/var/www/example.com...