MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

Apache: Comprehensive list of Apache HTTP Server configuration directives

This page lists the Apache HTTP Server 2.4 configuration directives you will see most often in httpd.conf, virtual host files and SSL configs, grouped by function. Below the list you will find which module provides each directive, where it is allowed, a working virtual host and MPM example, a migration table for legacy directives, and the commands to test a configuration before reloading.

Here is a comprehensive list of Apache HTTP Server configuration directives you might encounter in httpd.conf and included config files (like extra/httpd-vhosts.conf, extra/httpd-ssl.conf, etc). Apache has hundreds of directivesโ€”here are the most common and important ones, grouped by function. (For a complete official list, see: Apache Directives Index)


Core Server Directives

  • ServerName
  • ServerAlias
  • ServerAdmin
  • DocumentRoot
  • Listen
  • User
  • Group
  • PidFile
  • Timeout
  • KeepAlive
  • KeepAliveTimeout
  • MaxKeepAliveRequests
  • ServerTokens
  • ServerSignature
  • ServerRoot
  • HostnameLookups
  • LimitRequestBody
  • LimitRequestFields
  • LimitRequestFieldSize
  • LimitRequestLine

Directory and File Handling

  • DirectoryIndex
  • Options
  • AllowOverride
  • Require
  • Order (legacy)
  • Allow (legacy)
  • Deny (legacy)
  • AccessFileName
  • Files
  • Directory
  • Location
  • Alias
  • ScriptAlias
  • IndexOptions
  • IndexIgnore
  • Redirect
  • RedirectMatch

Logging

  • ErrorLog
  • CustomLog
  • LogLevel
  • LogFormat

Modules and Extensions

  • LoadModule
  • AddModule (legacy)
  • Include
  • TypesConfig
  • AddType
  • AddHandler
  • AddOutputFilter
  • AddInputFilter
  • AddLanguage
  • AddCharset
  • AddEncoding
  • AddIcon
  • AddDescription

Performance and Connection Handling

  • StartServers
  • MinSpareServers
  • MaxSpareServers
  • MaxClients (legacy; use MaxRequestWorkers)
  • MaxRequestWorkers
  • MaxConnectionsPerChild
  • ThreadsPerChild
  • ThreadLimit
  • ServerLimit

Security and Access Control

  • Require
  • AuthType
  • AuthName
  • AuthUserFile
  • AuthGroupFile
  • AuthBasicProvider
  • AllowOverride
  • SSLProtocol
  • SSLCipherSuite
  • SSLCertificateFile
  • SSLCertificateKeyFile
  • SSLCertificateChainFile
  • SSLEngine
  • SSLVerifyClient
  • SSLVerifyDepth
  • SSLProxyEngine

Virtual Hosting

  • VirtualHost
  • NameVirtualHost
  • UseCanonicalName
  • ServerAlias
  • ServerAdmin
  • DocumentRoot
  • ErrorLog
  • CustomLog
  • SSLEngine (for SSL vhosts)

Proxy and Reverse Proxy

  • ProxyRequests
  • ProxyPass
  • ProxyPassReverse
  • ProxyPreserveHost
  • ProxyTimeout
  • ProxyAddHeaders
  • ProxyVia
  • ProxyPassMatch

URL Rewriting

  • RewriteEngine
  • RewriteCond
  • RewriteRule
  • RewriteBase
  • RewriteMap

MIME Types and Content Handling

  • TypesConfig
  • DefaultType
  • AddType
  • AddEncoding
  • AddLanguage
  • AddCharset

Other Useful Directives

  • SetEnv
  • PassEnv
  • UnsetEnv
  • Header
  • RequestHeader
  • SetHandler
  • ScriptAlias
  • ScriptAliasMatch
  • ScriptInterpreterSource
  • SuexecUserGroup

Legacy and Deprecated Directives

(Some older directives are still seen in configs, though they’re deprecated)

  • Order
  • Allow
  • Deny
  • NameVirtualHost
  • MaxClients

How to Get the Full List on Your Server

You can get a list of all directives supported by your current Apache install with:

apachectl -L

or

httpd -L

This prints all recognized directives with a brief description.


Official Full List (by Module)

For the complete and always up-to-date list, see:
๐Ÿ‘‰ https://httpd.apache.org/docs/current/mod/directives.html



How Apache applies a directive: contexts and merge order

A directive name on its own is not enough. Every directive is valid only in certain contexts, and Apache refuses to start if you put one in the wrong place. The official documentation shows the allowed contexts for each directive, and httpd -L prints them for compiled-in modules.

ContextWhere it livesTypical directives
server configTop level of httpd.conf or an included fileListen, ServerRoot, LoadModule, User, MPM settings
virtual hostInside <VirtualHost>ServerName, DocumentRoot, SSLEngine, ProxyPass
directoryInside <Directory>, <Location>, <Files>Options, Require, AllowOverride (only in <Directory>)
.htaccessPer-directory files, only if AllowOverride permits itRewriteRule, Require, AddType

When several sections match a request, Apache merges them in this order, and later sections override earlier ones: <Directory> (non-regex) together with .htaccess, then <DirectoryMatch>, then <Files> and <FilesMatch>, then <Location> and <LocationMatch>, then <If>. So a <Location> block can override something set in a <Directory> block, but the reverse does not happen. Note that Directory, Location, Files and VirtualHost in the list above are container sections written with angle brackets, not ordinary directives.

Which module provides each directive

Most directives come from a module. If that module is not loaded, Apache stops with Invalid command '...', perhaps misspelled or defined by a module not included in the server configuration. This table maps the directives listed above to their modules.

ModuleDirectives from the list above
coreServerName, ServerAlias, ServerAdmin, ServerRoot, DocumentRoot, Timeout, KeepAlive*, ServerTokens, ServerSignature, HostnameLookups, LimitRequest*, Options, AllowOverride, AccessFileName, Include, ErrorLog, LogLevel, SetHandler, UseCanonicalName, ScriptInterpreterSource (Windows only)
MPM (prefork, worker, event)Listen, PidFile, StartServers, MaxRequestWorkers, MaxConnectionsPerChild, ServerLimit, ThreadsPerChild, ThreadLimit; MinSpareServers and MaxSpareServers are prefork only
mod_unixdUser, Group
mod_soLoadModule
mod_authz_core / mod_authz_hostRequire
mod_authn_core, mod_auth_basic, mod_authn_file, mod_authz_groupfileAuthType, AuthName, AuthBasicProvider, AuthUserFile, AuthGroupFile
mod_log_configCustomLog, LogFormat
mod_aliasAlias, ScriptAlias, ScriptAliasMatch, Redirect, RedirectMatch
mod_dir / mod_autoindexDirectoryIndex / IndexOptions, IndexIgnore, AddIcon, AddDescription
mod_mimeTypesConfig, AddType, AddHandler, AddOutputFilter, AddInputFilter, AddLanguage, AddCharset, AddEncoding
mod_env / mod_headersSetEnv, PassEnv, UnsetEnv / Header, RequestHeader
mod_rewrite, mod_proxy, mod_ssl, mod_suexecRewrite*, Proxy*, SSL*, SuexecUserGroup
mod_access_compatOrder, Allow, Deny (legacy)

On Debian and Ubuntu, enable modules with a2enmod (for example sudo a2enmod ssl proxy proxy_http headers rewrite). On RHEL, Rocky and Fedora, modules are loaded from /etc/httpd/conf.modules.d/. For optional settings in shared configs, you can wrap them in <IfModule mod_name.c> so they apply only when the module is loaded. Avoid this for directives your site depends on, because it hides a missing module instead of failing loudly.

A working virtual host that combines the common directives

The configuration below uses most of the core, SSL, proxy, header and logging directives from the list above. It redirects HTTP to HTTPS, serves static files and reverse-proxies /api/ to a local application. It requires mod_ssl, mod_proxy, mod_proxy_http and mod_headers, and a Listen 443 line, which the default SSL configuration usually provides.

<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com
    Redirect permanent / https://example.com/
</VirtualHost>

<VirtualHost *:443>
    ServerName example.com
    ServerAlias www.example.com
    ServerAdmin webmaster@example.com
    DocumentRoot /var/www/example

    SSLEngine on
    # Certificate plus intermediate chain in one file
    SSLCertificateFile    /etc/ssl/example/fullchain.pem
    SSLCertificateKeyFile /etc/ssl/example/privkey.pem

    <Directory /var/www/example>
        Options -Indexes +FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>

    # Reverse proxy; ProxyRequests stays Off (the default)
    ProxyPreserveHost On
    ProxyPass        /api/ http://127.0.0.1:8080/
    ProxyPassReverse /api/ http://127.0.0.1:8080/

    Header always set Strict-Transport-Security "max-age=31536000"
    Header always set X-Content-Type-Options "nosniff"

    # Adjust log paths for your distribution (/var/log/apache2 on Debian)
    ErrorLog  /var/log/httpd/example_error.log
    CustomLog /var/log/httpd/example_access.log combined
</VirtualHost>Code language: PHP (php)
  • ServerName and ServerAlias decide which name-based virtual host answers a request. If no name matches, the first vhost defined for that IP and port answers.
  • Options -Indexes turns off directory listings. AllowOverride None stops Apache from looking for .htaccess files, which is safer and faster.
  • ProxyPreserveHost On forwards the original Host header to the backend. ProxyPassReverse rewrites Location headers in backend redirects so clients are not sent to 127.0.0.1.
  • Header always set adds the header to error responses as well, not only to 2xx responses.

Note: Never set ProxyRequests On on a reverse proxy. It turns the server into a forward proxy, and if access is not restricted, anyone can use it as an open proxy.

Tuning the MPM directives together

The performance directives depend on each other, so change them as a set. Most current Linux packages use the event MPM. Run apachectl -V | grep -i mpm to check which MPM your server uses. A typical event MPM block looks like this:

<IfModule mpm_event_module>
    StartServers             3
    MinSpareThreads         75
    MaxSpareThreads        250
    ThreadLimit             64
    ThreadsPerChild         25
    ServerLimit             16
    MaxRequestWorkers      400
    MaxConnectionsPerChild   0
</IfModule>Code language: HTML, XML (xml)
  • MaxRequestWorkers is the maximum number of requests served at the same time. With threaded MPMs it must not exceed ServerLimit ร— ThreadsPerChild (here 16 ร— 25 = 400).
  • ThreadsPerChild cannot be higher than ThreadLimit. Changes to ServerLimit and ThreadLimit need a full restart, not a graceful reload.
  • MaxConnectionsPerChild 0 means child processes are never recycled. Set a value such as 10000 if a module leaks memory.
  • With prefork (often needed for non-thread-safe mod_php setups), use MinSpareServers and MaxSpareServers. Size MaxRequestWorkers so that it multiplied by the average process memory fits in RAM.

If the error log shows server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting, requests are queuing. Raise the limit only if you have spare CPU and memory. Otherwise, look at slow backends and the KeepAliveTimeout value first.

Replacing legacy and deprecated directives

The legacy section above is not complete, and some entries elsewhere in the list are deprecated without saying so. Use this table when you migrate older configurations to Apache 2.4.

Legacy directiveStatus in 2.4Replacement
Order, Allow, DenyWork only if mod_access_compat is loadedRequire all granted, Require all denied, Require ip 10.0.0.0/8, Require host example.com
NameVirtualHostHas no effect and logs a warningDelete it. Name-based vhosts are automatic.
MaxClientsOld name still acceptedMaxRequestWorkers
MaxRequestsPerChildOld name still acceptedMaxConnectionsPerChild
AddModuleRemoved back in Apache 2.0LoadModule only
SSLCertificateChainFileDeprecated since 2.4.8Put the certificate and its intermediates in the file named by SSLCertificateFile
DefaultTypeOnly the value none is allowedForceType or AddType, or a correct TypesConfig
# Apache 2.2 style
Order deny,allow
Deny from all
Allow from 192.168.1.0/24

# Apache 2.4 equivalent
Require ip 192.168.1.0/24Code language: PHP (php)

Note: Do not mix Order/Allow/Deny and Require in the same context. Their interaction is confusing and often produces client denied by server configuration errors. Convert everything to Require.

Inspecting and testing the configuration on your server

The apachectl -L command shown above lists only the directives from modules compiled into the binary. Modules loaded with LoadModule, which is how most distribution packages ship mod_ssl, mod_proxy and mod_rewrite, do not appear. Use the commands below to see what your running configuration actually uses. On Debian and Ubuntu, use apache2ctl and apache2 instead of httpd.

# Check syntax before every reload (prints "Syntax OK")
sudo apachectl configtest

# Show loaded modules, both static and shared
sudo apachectl -M

# Show which vhost answers which name and port
sudo apachectl -S

# Show version, MPM and compiled-in paths
apachectl -V

# Apply changes without dropping active connections
sudo apachectl -k graceful
# or: sudo systemctl reload httpd   (apache2 on Debian/Ubuntu)Code language: PHP (php)

apachectl -S is the fastest way to debug virtual host problems. It shows the default vhost for each address and port and the file and line where each vhost is defined.

Common errors and fixes

ErrorCauseFix
Invalid command 'ProxyPass', perhaps misspelled...The module that provides the directive is not loadedLoad it: a2enmod proxy proxy_http, or add the LoadModule line
Could not reliably determine the server's fully qualified domain nameNo global ServerNameAdd ServerName your.host.name at server level
client denied by server configurationNo Require all granted for the path, or mixed legacy and new access rulesAdd a Require rule in the matching <Directory>
could not bind to address 0.0.0.0:80Duplicate Listen line or another process using the portRemove the duplicate; check the port with ss -ltnp
NameVirtualHost has no effect...Leftover 2.2 directiveDelete the line
Wrong site served for a domainServerName/ServerAlias mismatch; the first vhost acts as the defaultCheck with apachectl -S

Security baseline directives

These server-level settings are a reasonable hardened starting point for most deployments:

ServerTokens Prod
ServerSignature Off
TraceEnable Off

<Directory />
    Options None
    AllowOverride None
    Require all denied
</Directory>

SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
SSLHonorCipherOrder off

LimitRequestBody 10485760Code language: HTML, XML (xml)
  • ServerTokens Prod reduces the Server header to just Apache, and ServerSignature Off removes the version footer from error pages.
  • Denying / and then granting access only to your DocumentRoot directories stops Apache from serving files you did not mean to publish.
  • TraceEnable Off disables the HTTP TRACE method, which is rarely needed.
  • LimitRequestBody caps request bodies (10 MB here). Raise it for upload endpoints inside a specific <Location>.

Frequently asked questions

Where is the Apache configuration file located?

On RHEL, Rocky and Fedora it is /etc/httpd/conf/httpd.conf, with extra files in conf.d/ and conf.modules.d/. On Debian and Ubuntu it is /etc/apache2/apache2.conf, with sites in sites-available/ and sites-enabled/. Run apachectl -V and look at HTTPD_ROOT and SERVER_CONFIG_FILE to confirm.

Why does apachectl -L not show SSL or proxy directives?

The -L option lists only directives from modules compiled into the binary. Modules loaded with LoadModule, such as mod_ssl and mod_proxy on most distributions, are not included. Use apachectl -M to see the loaded modules and the official directive index for their directives.

Is NameVirtualHost still needed in Apache 2.4?

No. Since 2.4, name-based virtual hosting works automatically for any address and port that has more than one <VirtualHost>. The directive has no effect and only causes a warning, so remove it.

Should I use .htaccess or the main configuration?

Use the main configuration or vhost files whenever you can, and set AllowOverride None. Apache then does not have to check for .htaccess files on every request, and the rules stay in one reviewed place. Use .htaccess only when users cannot edit the server configuration, such as on shared hosting.

Do I need a restart or a reload after changing directives?

Most changes take effect with a graceful reload (apachectl -k graceful or systemctl reload). Changes to ServerLimit and ThreadLimit need a full restart. Run apachectl configtest first in either case.

Related tutorials

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

Install and Configure Gerrit on CentOS and Ubuntu (MySQL + Apache Reverse Proxy)

A practical, step-by-step guide to installing Gerrit for code review on CentOS/RHEL and Ubuntu/Debian. Includes package command comparisons, setup workflow, Apache proxy configuration, and verification checks.

Read More

Install Apache on Windows 7 (Legacy): MSI Setup, UAC Prompts, and PHP Integration

A practical, legacy-focused guide to installing Apache HTTP Server on Windows 7 for local development. It covers package selection, UAC behavior, verification steps, and basic PHP wiring.

Read More

CollabNet Subversion Edge (2010): Bundling SVN, Apache, and ViewVC for Easier Administration

This revised technical brief explains what CollabNetโ€™s Subversion Edge beta promised in 2010, how it changed day-to-day SVN operations, and what DevOps teams can still learn from that model.

Read More

Install Subversion (SVN) on Linux: Package Install, Source Build, Apache Setup, and Authentication

Learn how to install Subversion on Linux, create a repository, and publish it through Apache with user authentication. This revised guide includes both package-based and legacy source-build paths with practical commands.

Read More

Apache Interview Questions (Updated): Practical DevOps Answers with Modern Config and Operations

A revised Apache interview kit that explains not just what to answer, but how to operate Apache safely in production. Covers commands, process model, config validation, virtual hosts, and access control.

Read More

Apache and HTTP Interview Questions: Updated Answers for DevOps Engineers

A modernized Apache and HTTP interview guide with practical, production-focused answers. Includes command comparisons, config examples, and a safe change workflow.

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x