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.
| Context | Where it lives | Typical directives |
|---|---|---|
| server config | Top level of httpd.conf or an included file | Listen, ServerRoot, LoadModule, User, MPM settings |
| virtual host | Inside <VirtualHost> | ServerName, DocumentRoot, SSLEngine, ProxyPass |
| directory | Inside <Directory>, <Location>, <Files> | Options, Require, AllowOverride (only in <Directory>) |
| .htaccess | Per-directory files, only if AllowOverride permits it | RewriteRule, 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.
| Module | Directives from the list above |
|---|---|
| core | ServerName, 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_unixd | User, Group |
| mod_so | LoadModule |
| mod_authz_core / mod_authz_host | Require |
| mod_authn_core, mod_auth_basic, mod_authn_file, mod_authz_groupfile | AuthType, AuthName, AuthBasicProvider, AuthUserFile, AuthGroupFile |
| mod_log_config | CustomLog, LogFormat |
| mod_alias | Alias, ScriptAlias, ScriptAliasMatch, Redirect, RedirectMatch |
| mod_dir / mod_autoindex | DirectoryIndex / IndexOptions, IndexIgnore, AddIcon, AddDescription |
| mod_mime | TypesConfig, AddType, AddHandler, AddOutputFilter, AddInputFilter, AddLanguage, AddCharset, AddEncoding |
| mod_env / mod_headers | SetEnv, PassEnv, UnsetEnv / Header, RequestHeader |
| mod_rewrite, mod_proxy, mod_ssl, mod_suexec | Rewrite*, Proxy*, SSL*, SuexecUserGroup |
| mod_access_compat | Order, 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)
ServerNameandServerAliasdecide which name-based virtual host answers a request. If no name matches, the first vhost defined for that IP and port answers.Options -Indexesturns off directory listings.AllowOverride Nonestops Apache from looking for.htaccessfiles, which is safer and faster.ProxyPreserveHost Onforwards the originalHostheader to the backend.ProxyPassReverserewritesLocationheaders in backend redirects so clients are not sent to127.0.0.1.Header always setadds 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)
MaxRequestWorkersis the maximum number of requests served at the same time. With threaded MPMs it must not exceedServerLimitรThreadsPerChild(here 16 ร 25 = 400).ThreadsPerChildcannot be higher thanThreadLimit. Changes toServerLimitandThreadLimitneed a full restart, not a graceful reload.MaxConnectionsPerChild 0means 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
MinSpareServersandMaxSpareServers. SizeMaxRequestWorkersso 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 directive | Status in 2.4 | Replacement |
|---|---|---|
Order, Allow, Deny | Work only if mod_access_compat is loaded | Require all granted, Require all denied, Require ip 10.0.0.0/8, Require host example.com |
NameVirtualHost | Has no effect and logs a warning | Delete it. Name-based vhosts are automatic. |
MaxClients | Old name still accepted | MaxRequestWorkers |
MaxRequestsPerChild | Old name still accepted | MaxConnectionsPerChild |
AddModule | Removed back in Apache 2.0 | LoadModule only |
SSLCertificateChainFile | Deprecated since 2.4.8 | Put the certificate and its intermediates in the file named by SSLCertificateFile |
DefaultType | Only the value none is allowed | ForceType 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
| Error | Cause | Fix |
|---|---|---|
Invalid command 'ProxyPass', perhaps misspelled... | The module that provides the directive is not loaded | Load it: a2enmod proxy proxy_http, or add the LoadModule line |
Could not reliably determine the server's fully qualified domain name | No global ServerName | Add ServerName your.host.name at server level |
client denied by server configuration | No Require all granted for the path, or mixed legacy and new access rules | Add a Require rule in the matching <Directory> |
could not bind to address 0.0.0.0:80 | Duplicate Listen line or another process using the port | Remove the duplicate; check the port with ss -ltnp |
NameVirtualHost has no effect... | Leftover 2.2 directive | Delete the line |
| Wrong site served for a domain | ServerName/ServerAlias mismatch; the first vhost acts as the default | Check 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 Prodreduces theServerheader to justApache, andServerSignature Offremoves the version footer from error pages.- Denying
/and then granting access only to yourDocumentRootdirectories stops Apache from serving files you did not mean to publish. TraceEnable Offdisables the HTTP TRACE method, which is rarely needed.LimitRequestBodycaps 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
- More Networking tutorials
- Network Engineer: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path
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.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services โ all in one place.
Explore Hospitals