Bare minimum Apache modules needed for static website and no authN

The answer is alluded to in the official 2.2 docs, in the section on performance tuning.

An associated question that arises here is, of course, what modules you need, and which ones you don't. The answer here will, of course, vary from one web site to another. However, the minimal list > of modules which you can get by with tends to include mod_mime, mod_dir, and mod_log_config. mod_log_config is, of course, optional, as you can run a web site without log files. This is, however, not recommended.


Just noticed this question as I was setting up a new PC with Apache 2.2. Here's the absolute minimum httpd.conf I managed to come up with:

    ServerName 127.0.0.1
    Listen 8080
    LoadModule dir_module modules/mod_dir.so
    LoadModule mime_module modules/mod_mime.so
    DirectoryIndex index.html 
    DocumentRoot "C:/http_root"
    ErrorLog "logs/error.log"
    LogLevel warn                

You don't need the ErrorLog of course, but I was experimenting so obviously needed some feedback if my httpd.conf file was causing problems. You need ServerName to avoid a warning during startup about not being able to reliably determine the server address. I can certainly confirm that you do need dir_module and mime_module so that you can deliver a default file from a directory URL and also display the file as HTML rather than plain text.

I'm posting this because I find the default httpd.conf file overwhelmingly complicated and I remembered that when I was learning Tomcat, everything became a lot clearer when I discovered the absolute minimum server configuration file.

If you want to server php pages, you just need the following 2 lines (adjusted to suit your environment:

PHPIniDir "C:/php/"
LoadModule php5_module "C:/php/php5apache2_2.dll"

This took a morning to work out by trial and error but on Red hat 6 (ish) this works, note I've had to override an existing .htaccess file that I can't change. This will point to offline.html in your root directory

ServerName 127.0.0.1
Listen 80
TypesConfig /etc/mime.types
LoadModule dir_module modules/mod_dir.so
LoadModule mime_module modules/mod_mime.so
LoadModule rewrite_module modules/mod_rewrite.so

User apache
Group apache
DocumentRoot "/homedir/"
DirectoryIndex offline.html
ErrorLog "/homedir/error.log"
LogLevel warn  

<Directory />
AllowOverride None
</Directory>

If you don't need to override htaccess file you could probably get away with this (assuming you want error logging):

ServerName 127.0.0.1
Listen 80
TypesConfig /etc/mime.types
LoadModule dir_module modules/mod_dir.so
LoadModule mime_module modules/mod_mime.so

User apache
Group apache
DocumentRoot "/homedir/"
DirectoryIndex offline.html
ErrorLog "/homedir/error.log"
LogLevel warn