Disable Directory listing in Apache running on Ubuntu

If when browsing your website you come across directories that looks like this:

imageimage

then directory listing is enabled in your web server. I believe in Ubuntu directory listing is enabled by default when you install Apache. I don’t know why this is enabled by default, because it might be a security issue, and might slow down the web server performance as well.

to disable directory listing in Ubuntu, just SSH to your web server and run this command:

sudo a2dismod autoindex

then reload apache:

sudo service apache2 reload

that’s it. now directory listing should be disabled in your web server, and when trying to access any directory on your web server from you browser,  you should get the following error now:

image

More Linux Tutorials