The `mod_autoindex` module is used in Apache web server to list the contents of the directories that have no index (`index.html`, `index.php`, etc.). It’s used when you want to show the files and subdirectories of a particular directory in a webpage.
Here’s how to configure mod\_autoindex module in Apache:
1. Enable mod\_autoindex module: Depending on the Apache installation, the module might be available by default. If not, you would need to enable it. On Ubuntu/Debian, you can do so with the following command:
```
sudo a2enmod autoindex
```
On RedHat/CentOS, ensure the following line is un-commented in `httpd.conf`:
```
LoadModule autoindex_module modules/mod_autoindex.so
```
1. Basic Configuration: To enable automatic directory listing, you add `Options +Indexes` directive in the `Directory` tag:
```
```
1. Detailed Configuration: The `IndexOptions` directive is used for customizing the appearance of the file list. For example,
```
```
Here `FancyIndexing` is for fancy file listings, `VersionSort` is for sorting files containing version numbers, `NameWidth=*` is for dynamically sizing column width, `HTMLTable` is for using HTML tables for the layout, `Charset=UTF-8` is for setting charset.
1. Header and Readme Files: If you want custom Header and Footer (readme) for your directory listings, you can do it with `HeaderName` and `ReadmeName` directives like:
```
```
1. Excluding Files: `IndexIgnore` directive specifies files to hide in the listing:
```
```
1. After making changes, don’t forget to restart the Apache server:
```
sudo systemctl restart apache2 ## Ubuntu/Debian
sudo systemctl restart httpd ## RedHat/CentOS
```
Remember that if Apache is not configured safely, directory listing can lead to revealing sensitive information. Always be careful to only list directories that you want users to see.
Ensure you have the required permissions to make these changes and always backup your configuration files before making any alterations.