Table of Contents

Apache HTTP Server Configuration Examples

Apache Default Configuration : Source httpd-2.4

Environment

# tree /usr/local/apache2/conf
/usr/local/apache2/conf
├── extra
│   ├── httpd-autoindex.conf
│   ├── httpd-dav.conf
│   ├── httpd-default.conf
│   ├── httpd-info.conf
│   ├── httpd-languages.conf
│   ├── httpd-manual.conf
│   ├── httpd-mpm.conf
│   ├── httpd-multilang-errordoc.conf
│   ├── httpd-ssl.conf
│   ├── httpd-userdir.conf
│   ├── httpd-vhosts.conf
│   └── proxy-html.conf
├── httpd.conf
├── magic
├── mime.types
└── original
    ├── extra
    │   ├── httpd-autoindex.conf
    │   ├── httpd-dav.conf
    │   ├── httpd-default.conf
    │   ├── httpd-info.conf
    │   ├── httpd-languages.conf
    │   ├── httpd-manual.conf
    │   ├── httpd-mpm.conf
    │   ├── httpd-multilang-errordoc.conf
    │   ├── httpd-ssl.conf
    │   ├── httpd-userdir.conf
    │   ├── httpd-vhosts.conf
    │   └── proxy-html.conf
    └── httpd.conf

3 directories, 28 files


(abbr)/conf/httpd.conf

# grep -Ev "^*#|^$" /usr/local/apache2/conf/httpd.conf
ServerRoot "/usr/local/apache-2.4.23"
Listen 80
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule filter_module modules/mod_filter.so
LoadModule mime_module modules/mod_mime.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule dir_module modules/mod_dir.so
LoadModule alias_module modules/mod_alias.so
<IfModule unixd_module>
User daemon
Group daemon
</IfModule>
ServerAdmin you@example.com
<Directory />
    AllowOverride none
    Require all denied
</Directory>
DocumentRoot "/usr/local/apache-2.4.23/htdocs"
<Directory "/usr/local/apache-2.4.23/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>
<Files ".ht*">
    Require all denied
</Files>
ErrorLog "logs/error_log"
LogLevel warn
<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>
    CustomLog "logs/access_log" common
</IfModule>
<IfModule alias_module>
    ScriptAlias /cgi-bin/ "/usr/local/apache-2.4.23/cgi-bin/"
</IfModule>
<IfModule cgid_module>
</IfModule>
<Directory "/usr/local/apache-2.4.23/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>
<IfModule mime_module>
    TypesConfig conf/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
</IfModule>
<IfModule proxy_html_module>
Include conf/extra/proxy-html.conf
</IfModule>
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
#

Settings that are commented out by default

# Server-pool management (MPM specific)
#Include conf/extra/httpd-mpm.conf

# Real-time info on requests and configuration
#Include conf/extra/httpd-info.conf

# Various default settings
#Include conf/extra/httpd-default.conf


(abbr)/conf/extra/httpd-mpm.conf

If you want to use httpd-mpm.conf, You must include httpd-mpm.conf in httpd.conf

Include conf/extra/httpd-mpm.conf

# grep -Ev "^*#|^$"  /usr/local/apache2/conf/extra/httpd-mpm.conf 
<IfModule !mpm_netware_module>
    PidFile "logs/httpd.pid"
</IfModule>
<IfModule mpm_prefork_module>
    StartServers             5
    MinSpareServers          5
    MaxSpareServers         10
    MaxRequestWorkers      250
    MaxConnectionsPerChild   0
</IfModule>
<IfModule mpm_worker_module>
    StartServers             3
    MinSpareThreads         75
    MaxSpareThreads        250 
    ThreadsPerChild         25
    MaxRequestWorkers      400
    MaxConnectionsPerChild   0
</IfModule>
<IfModule mpm_event_module>
    StartServers             3
    MinSpareThreads         75
    MaxSpareThreads        250
    ThreadsPerChild         25
    MaxRequestWorkers      400
    MaxConnectionsPerChild   0
</IfModule>
<IfModule mpm_netware_module>
    ThreadStackSize      65536
    StartThreads           250
    MinSpareThreads         25
    MaxSpareThreads        250
    MaxThreads            1000
    MaxConnectionsPerChild   0
</IfModule>
<IfModule mpm_mpmt_os2_module>
    StartServers             2
    MinSpareThreads          5
    MaxSpareThreads         10
    MaxConnectionsPerChild   0
</IfModule>
<IfModule mpm_winnt_module>
    ThreadsPerChild        150
    MaxConnectionsPerChild   0
</IfModule>
<IfModule !mpm_netware_module>
    MaxMemFree            2048
</IfModule>
<IfModule mpm_netware_module>
    MaxMemFree             100
</IfModule>


(abbr)/conf/extra/httpd-info.conf

If you want to use httpd-info.conf, You must include httpd-info.conf in httpd.conf

Include conf/extra/httpd-info.conf

# grep -Ev "^*#|^$"  /usr/local/apache2/conf/extra/httpd-info.conf 
<Location /server-status>
    SetHandler server-status
    Require host .example.com
    Require ip 127
</Location>
<Location /server-info>
    SetHandler server-info
    Require host .example.com
    Require ip 127
</Location>