Today, we will be working with apache2. This has been tested it on Ubuntu.
Let’s say we have a folder called files on the Apache web server /var/www/html/. If we go to the URL http://your_ip_or_dns/files/, we would see files folder something like this.

lsxalws

There are different methods for solving this problem. We will look into one of them. Let’s open-up the configuration file of apache2, called apache2.conf located at /etc/apache2 as

sudo nano /etc/apache2/apache2.conf

Go ahead and find the Directory node, especially the . Depending upon the setting, it looks as below.

b4eskjm

Change


        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted

To


        Options FollowSymLinks
        AllowOverride None
        Require all granted

i.e. remove the Indexes. Save the file and restart the apache2 server as:

sudo service apache2 restart

Go ahead and access the same address,http://your_ip_or_dns/files/ you should see the 403 Forbidden as

hdgnxri

Some management commands for apache2

To stop the web server

sudo service apache2 stop

To start the web server

sudo service apache2 start

After making changes in the configuration, you can reload it as

sudo service apache2 reload

To disable the web server

sudo service apache2 disable

To enable the web server

sudo service apache2 enable

The access log and error log are located at /var/log/apache2/access.log and /var/log/apache2/error.log
respectively by default.

Get to know about the different configuration options here