Minimal Apache Configuration
Posted Jan 2 2015, 04:17 by William Shallum [updated Jul 5 2015, 08:18]
The default Apache config file is huge (and heavily commented) compared to e.g. nginx. How small can you make the config file if you just want to get it up?
Here’s what I came up with for Apache 2.4 (note: mime.types not included)
# logs
ErrorLog /dev/stdout
PidFile httpd.pid
# select MPM
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
# must load security module
LoadModule unixd_module modules/mod_unixd.so
# must load authn_core
LoadModule authn_core_module modules/mod_authn_core.so
# and authz_core for "Require all granted"
LoadModule authz_core_module modules/mod_authz_core.so
# to enable index (default index.html)
LoadModule dir_module modules/mod_dir.so
# to enable autoindex
LoadModule autoindex_module modules/mod_autoindex.so
# to load mime types
LoadModule mime_module modules/mod_mime.so
# in case people want to rewrite via .htaccess
LoadModule rewrite_module modules/mod_rewrite.so
Listen [::1]:8000
Listen 127.0.0.1:8000
# dev server does not need lots of spare servers
MaxSpareServers 2
MinSpareServers 1
StartServers 3
# the default for prefork MaxRequestWorkers / MaxClients is 256, should be enough
TypesConfig mime.types
DocumentRoot "/doc/root"
<Directory />
Require all denied
AllowOverride None
</Directory>
<Directory "/doc/root">
Require all granted
Options +Indexes
AllowOverride All
</Directory>
The minimal is not so big after all. It is a little annoying that some modules HAVE to be loaded otherwise the server won’t run. I have a script to serve up a local directory here (with optional PHP support): https://github.com/wshallum/serveup
Other references: