Description: | A collection of directives that are implemented bymore than one multi-processing module (MPM) |
---|---|
Status: | MPM |
Description: | Directory where Apache HTTP Server attempts toswitch before dumping core |
---|---|
Syntax: | CoreDumpDirectorydirectory |
Default: | See usage for the default setting |
Context: | server config |
Status: | MPM |
Module: | event ,worker ,prefork |
This controls the directory to which Apache httpd attempts to switch before dumping core. If your operating system is configured to create core files in the working directory of the crashing process,CoreDumpDirectory
is necessary to change working directory from the defaultServerRoot
directory, which should not be writable by the user the server runs as.
If you want a core dump for debugging, you can use this directive to place it in a different location. This directive has no effect if your operating system is not configured to write core files to the working directory of the crashing processes.
Using this directive on Linux may allow other processes on the system (if running with similar privileges, such as CGI scripts) to attach to httpd children via theptrace
system call. This may make weaken the protection from certain security attacks. It is not recommended to use this directive on production systems.
If Apache httpd starts as root and switches to another user, the Linux kerneldisables core dumps even if the directory is writable for the process. Apache httpd (2.0.46 and later) reenables core dumps on Linux 2.4 and beyond, but only if you explicitly configure aCoreDumpDirectory
.
To enable core-dumping of suid-executables on BSD-systems (such as FreeBSD), setkern.sugid_coredump
to 1.
CoreDumpDirectory
processing only occurs for a select set of fatal signals: SIGFPE, SIGILL, SIGABORT, SIGSEGV, and SIGBUS.
On some operating systems, SIGQUIT also results in a core dump but does not go throughCoreDumpDirectory
orEnableExceptionHook
processing, so the core location is dictated entirely by the operating system.
Description: | Enables a hook that runs exception handlersafter a crash |
---|---|
Syntax: | EnableExceptionHook On|Off |
Default: | EnableExceptionHook Off |
Context: | server config |
Status: | MPM |
Module: | event ,worker ,prefork |
For safety reasons this directive is only available if the server was configured with the--enable-exception-hook
option. It enables a hook that allows external modules to plug in and do something after a child crashed.
There are already two modules,mod_whatkilledus
andmod_backtrace
that make use of this hook. Please have a look at Jeff Trawick'sEnableExceptionHook site for more information about these.
Description: | Specify a timeout after which a gracefully shutdown serverwill exit. |
---|---|
Syntax: | GracefulShutdownTimeoutseconds |
Default: | GracefulShutdownTimeout 0 |
Context: | server config |
Status: | MPM |
Module: | event ,worker ,prefork |
Compatibility: | Available in version 2.2 and later |
TheGracefulShutdownTimeout
specifies how many seconds after receiving a "graceful-stop" signal, a server should continue to run, handling the existing connections.
Setting this value to zero means that the server will wait indefinitely until all remaining requests have been fully served.
Description: | IP addresses and ports that the serverlistens to |
---|---|
Syntax: | Listen [IP-address:]portnumber [protocol] |
Context: | server config |
Status: | MPM |
Module: | event ,worker ,prefork ,mpm_winnt ,mpm_netware ,mpmt_os2 |
Compatibility: | Theprotocol argument was added in 2.1.5 |
TheListen
directive instructs Apache httpd to listen to only specific IP addresses or ports; by default it responds to requests on all IP interfaces.Listen
is now a required directive. If it is not in the config file, the server will fail to start. This is a change from previous versions of Apache httpd.
TheListen
directive tells the server to accept incoming requests on the specified port or address-and-port combination. If only a port number is specified, the server listens to the given port on all interfaces. If an IP address is given as well as a port, the server will listen on the given port and interface.
MultipleListen
directives may be used to specify a number of addresses and ports to listen to. The server will respond to requests from any of the listed addresses and ports.
For example, to make the server accept connections on both port 80 and port 8000, use:
Listen 80Listen 8000
To make the server accept connections on two specified interfaces and port numbers, use
Listen 192.170.2.1:80Listen 192.170.2.5:8000
IPv6 addresses must be surrounded in square brackets, as in the following example:
Listen [2001:db8::a00:20ff:fea7:ccea]:80
The optionalprotocol argument is not required for most configurations. If not specified,https
is the default for port 443 andhttp
the default for all other ports. The protocol is used to determine which module should handle a request, and to apply protocol specific optimizations with theAcceptFilter
directive.
You only need to set the protocol if you are running on non-standard ports. For example, running anhttps
site on port 8443:
Listen 192.170.2.1:8443 https
Listen
directives for the same ip address and port will result in anAddress already in use
error message.Description: | Maximum length of the queue of pending connections |
---|---|
Syntax: | ListenBackLogbacklog |
Default: | ListenBackLog 511 |
Context: | server config |
Status: | MPM |
Module: | event ,worker ,prefork ,mpm_winnt ,mpm_netware ,mpmt_os2 |
The maximum length of the queue of pending connections. Generally no tuning is needed or desired; however on some systems, it is desirable to increase this when under a TCP SYN flood attack. See the backlog parameter to thelisten(2)
system call.
This will often be limited to a smaller number by the operating system. This varies from OS to OS. Also note that many OSes do not use exactly what is specified as the backlog, but use a number based on (but normally larger than) what is set.
Description: | Ratio between the number of CPU cores (online) and the number oflisteners' buckets |
---|---|
Syntax: | ListenCoresBucketsRatioratio |
Default: | ListenCoresBucketsRatio 0 (disabled) |
Context: | server config |
Status: | MPM |
Module: | event ,worker ,prefork |
Compatibility: | Available in Apache HTTP Server 2.4.17, with a kernel supportingthe socket optionSO_REUSEPORT and distributing new connectionsevenly across listening processes' (or threads') sockets using it (eg. Linux3.9 and later, but not the current implementations ofSO_REUSEPORT in *BSDs. |
Aratio between the number of (online) CPU cores and the number of listeners' buckets can be used to make Apache HTTP Server createnum_cpu_cores / ratio
listening buckets, each containing its ownListen
-ing socket(s) on the same port(s), and then make each child handle a single bucket (with round-robin distribution of the buckets at children creation time).
On Linux (and also BSD) a CPU core can be turned on/off ifHotplug is configured, thereforeListenCoresBucketsRatio
needs to take this parameter into account while calculating the number of buckets to create.
ListenCoresBucketsRatio
can improve the scalability when accepting new connections is/becomes the bottleneck. On systems with a large number of CPU cores, enabling this feature has been tested to show significant performances improvement and shorter responses time.
There must be at least twice the number of CPU cores than the configuredratio for this to be active. The recommendedratio is8
, hence at least16
cores should be available at runtime when this value is used. The rightratio to obtain maximum performance needs to be calculated for each target system, testing multiple values and observing the variations in your key performance metrics.
This directive influences the calculation of theMinSpareThreads
andMaxSpareThreads
lower bound values. The number of children processes needs to be a multiple of the number of buckets to optimally accept connections.
Listen
ers or Apache HTTP servers on the same IP address and portSetting theSO_REUSEPORT
option on the listening socket(s) consequently allows multiple processes (sharing the sameEUID
, e.g.root
) to bind to the the same IP address and port, without the binding error raised by the system in the usual case.
This also means that multiple instances of Apache httpd configured on a sameIP:port
and with a positiveListenCoresBucketsRatio
would start without an error too, and then run with incoming connections evenly distributed across both instances (this is NOT a recommendation or a sensible usage in any case, but just a notice that it would prevent such possible issues to be detected).
Within the same instance, Apache httpd will check and fail to start if multipleListen
directives on the exact same IP (or hostname) and port are configured, thus avoiding the creation of some duplicated buckets which would be useless and kill performances. However it can't (and won't try harder to) catch all the possible overlapping cases (like a hostname resolving to an IP used elsewhere).
Description: | Limit on the number of connections that an individual child serverwill handle during its life |
---|---|
Syntax: | MaxConnectionsPerChildnumber |
Default: | MaxConnectionsPerChild 0 |
Context: | server config |
Status: | MPM |
Module: | event ,worker ,prefork ,mpm_winnt ,mpm_netware ,mpmt_os2 |
Compatibility: | Available Apache HTTP Server 2.3.9 and later. The old nameMaxRequestsPerChild is still supported. |
TheMaxConnectionsPerChild
directive sets the limit on the number of connections that an individual child server process will handle. AfterMaxConnectionsPerChild
connections, the child process will die. IfMaxConnectionsPerChild
is0
, then the process will never expire.
SettingMaxConnectionsPerChild
to a non-zero value limits the amount of memory that a process can consume by (accidental) memory leakage.
Description: | Maximum amount of memory that the main allocator is allowedto hold without callingfree() |
---|---|
Syntax: | MaxMemFreeKBytes |
Default: | MaxMemFree 2048 |
Context: | server config |
Status: | MPM |
Module: | event ,worker ,prefork ,mpm_winnt ,mpm_netware |
TheMaxMemFree
directive sets the maximum number of free Kbytes that every allocator is allowed to hold without callingfree()
. In threaded MPMs, every thread has its own allocator. When set to zero, the threshold will be set to unlimited.
Description: | Maximum number of connections that will be processedsimultaneously |
---|---|
Syntax: | MaxRequestWorkersnumber |
Default: | See usage for details |
Context: | server config |
Status: | MPM |
Module: | event ,worker ,prefork |
TheMaxRequestWorkers
directive sets the limit on the number of simultaneous requests that will be served. Any connection attempts over theMaxRequestWorkers
limit will normally be queued, up to a number based on theListenBacklog
directive. Once a child process is freed at the end of a different request, the connection will then be serviced.
For non-threaded servers (i.e.,prefork
),MaxRequestWorkers
translates into the maximum number of child processes that will be launched to serve requests. The default value is256
; to increase it, you must also raiseServerLimit
.
For threaded and hybrid servers (e.g.event
orworker
),MaxRequestWorkers
restricts the total number of threads that will be available to serve clients. For hybrid MPMs, the default value is16
(ServerLimit
) multiplied by the value of25
(ThreadsPerChild
). Therefore, to increaseMaxRequestWorkers
to a value that requires more than 16 processes, you must also raiseServerLimit
.
MaxRequestWorkers
was calledMaxClients
before version 2.3.13. The old name is still supported.
Description: | Maximum number of idle threads |
---|---|
Syntax: | MaxSpareThreadsnumber |
Default: | See usage for details |
Context: | server config |
Status: | MPM |
Module: | event ,worker ,mpm_netware ,mpmt_os2 |
Maximum number of idle threads. Different MPMs deal with this directive differently.
Forworker
andevent
, the default isMaxSpareThreads 250
. These MPMs deal with idle threads on a server-wide basis. If there are too many idle threads in the server, then child processes are killed until the number of idle threads is less than this number. Additional processes/threads might be created ifListenCoresBucketsRatio
is enabled.
Formpm_netware
the default isMaxSpareThreads 100
. Since this MPM runs a single-process, the spare thread count is also server-wide.
mpmt_os2
works similar tompm_netware
. Formpmt_os2
the default value is10
.
The range of theMaxSpareThreads
value is restricted. Apache httpd will correct the given value automatically according to the following rules:
mpm_netware
wants the value to be greater thanMinSpareThreads
.worker
andevent
, the value must be greater or equal to the sum of MinSpareThreads
andThreadsPerChild
.Description: | Minimum number of idle threads available to handle requestspikes |
---|---|
Syntax: | MinSpareThreadsnumber |
Default: | See usage for details |
Context: | server config |
Status: | MPM |
Module: | event ,worker ,mpm_netware ,mpmt_os2 |
Minimum number of idle threads to handle request spikes. Different MPMs deal with this directive differently.
worker
andevent
use a default ofMinSpareThreads 75
and deal with idle threads on a server-wide basis. If there aren't enough idle threads in the server, then child processes are created until the number of idle threads is greater thannumber. Additional processes/threads might be created ifListenCoresBucketsRatio
is enabled.
mpm_netware
uses a default ofMinSpareThreads 10
and, since it is a single-process MPM, tracks this on a server-wide basis.
mpmt_os2
works similar tompm_netware
. Formpmt_os2
the default value is5
.
Description: | File where the server records the process IDof the daemon |
---|---|
Syntax: | PidFilefilename |
Default: | PidFile logs/httpd.pid |
Context: | server config |
Status: | MPM |
Module: | event ,worker ,prefork ,mpm_winnt ,mpmt_os2 |
ThePidFile
directive sets the file to which the server records the process id of the daemon. If the filename is not absolute, then it is assumed to be relative to theServerRoot
.
PidFile /var/run/apache.pid
It is often useful to be able to send the server a signal, so that it closes and then re-opens itsErrorLog
andTransferLog
, and re-reads its configuration files. This is done by sending a SIGHUP (kill -1) signal to the process id listed in thePidFile
.
ThePidFile
is subject to the same warnings about log file placement andsecurity.
As of Apache HTTP Server 2, we recommended that you only use theapachectl
script, or the init script that your OS provides, for (re-)starting or stopping the server.
Description: | TCP receive buffer size |
---|---|
Syntax: | ReceiveBufferSizebytes |
Default: | ReceiveBufferSize 0 |
Context: | server config |
Status: | MPM |
Module: | event ,worker ,prefork ,mpm_winnt ,mpm_netware ,mpmt_os2 |
The server will set the TCP receive buffer size to the number of bytes specified.
If set to the value of0
, the server will use the OS default.
Description: | Location of the file used to store coordination data forthe child processes |
---|---|
Syntax: | ScoreBoardFilefile-path |
Default: | ScoreBoardFile logs/apache_runtime_status |
Context: | server config |
Status: | MPM |
Module: | event ,worker ,prefork ,mpm_winnt |
Apache HTTP Server uses a scoreboard to communicate between its parent and child processes. Some architectures require a file to facilitate this communication. If the file is left unspecified, Apache httpd first attempts to create the scoreboard entirely in memory (using anonymous shared memory) and, failing that, will attempt to create the file on disk (using file-based shared memory). Specifying this directive causes Apache httpd to always create the file on the disk.
ScoreBoardFile /var/run/apache_runtime_status
File-based shared memory is useful for third-party applications that require direct access to the scoreboard.
If you use aScoreBoardFile
, then you may see improved speed by placing it on a RAM disk. But be careful that you heed the same warnings about log file placement andsecurity.
Description: | TCP buffer size |
---|---|
Syntax: | SendBufferSizebytes |
Default: | SendBufferSize 0 |
Context: | server config |
Status: | MPM |
Module: | event ,worker ,prefork ,mpm_winnt ,mpm_netware ,mpmt_os2 |
Sets the server's TCP send buffer size to the number of bytes specified. It is often useful to set this past the OS's standard default value on high speed, high latency connections (i.e., 100ms or so, such as transcontinental fast pipes).
If set to the value of0
, the server will use the default value provided by your OS.
Further configuration of your operating system may be required to elicit better performance on high speed, high latency connections.
On some operating systems, changes in TCP behavior resulting from a largerSendBufferSize
may not be seen unlessEnableSendfile
is set to OFF. This interaction applies only to static files.
Description: | Upper limit on configurable number of processes |
---|---|
Syntax: | ServerLimitnumber |
Default: | See usage for details |
Context: | server config |
Status: | MPM |
Module: | event ,worker ,prefork |
For theprefork
MPM, this directive sets the maximum configured value forMaxRequestWorkers
for the lifetime of the Apache httpd process. For theworker
andevent
MPMs, this directive in combination withThreadLimit
sets the maximum configured value forMaxRequestWorkers
for the lifetime of the Apache httpd process. For theevent
MPM, this directive also defines how many old server processes may keep running and finish processing open connections. Any attempts to change this directive during a restart will be ignored, butMaxRequestWorkers
can be modified during a restart.
Special care must be taken when using this directive. IfServerLimit
is set to a value much higher than necessary, extra, unused shared memory will be allocated. If bothServerLimit
andMaxRequestWorkers
are set to values higher than the system can handle, Apache httpd may not start or the system may become unstable.
With theprefork
MPM, use this directive only if you need to setMaxRequestWorkers
higher than 256 (default). Do not set the value of this directive any higher than what you might want to setMaxRequestWorkers
to.
Withworker
, use this directive only if yourMaxRequestWorkers
andThreadsPerChild
settings require more than 16 server processes (default). Do not set the value of this directive any higher than the number of server processes required by what you may want forMaxRequestWorkers
andThreadsPerChild
.
Withevent
, increase this directive if the process number defined by yourMaxRequestWorkers
andThreadsPerChild
settings, plus the number of gracefully shutting down processes, is more than 16 server processes (default).
There is a hard limit ofServerLimit 20000
compiled into the server (for theprefork
MPM 200000). This is intended to avoid nasty effects caused by typos. To increase it even further past this limit, you will need to modify the value of MAX_SERVER_LIMIT in the mpm source file and rebuild the server.
Description: | Number of child server processes created at startup |
---|---|
Syntax: | StartServersnumber |
Default: | See usage for details |
Context: | server config |
Status: | MPM |
Module: | event ,worker ,prefork ,mpmt_os2 |
TheStartServers
directive sets the number of child server processes created on startup. As the number of processes is dynamically controlled depending on the load, (seeMinSpareThreads
,MaxSpareThreads
,MinSpareServers
,MaxSpareServers
) there is usually little reason to adjust this parameter.
The default value differs from MPM to MPM.worker
andevent
default toStartServers 3
; prefork
defaults to5
;mpmt_os2
defaults to2
.
Description: | Number of threads created on startup |
---|---|
Syntax: | StartThreadsnumber |
Default: | See usage for details |
Context: | server config |
Status: | MPM |
Module: | mpm_netware |
Number of threads created on startup. As the number of threads is dynamically controlled depending on the load, (seeMinSpareThreads
,MaxSpareThreads
,MinSpareServers
,MaxSpareServers
) there is usually little reason to adjust this parameter.
Formpm_netware
the default isStartThreads 50
and, since there is only a single process, this is the total number of threads created at startup to serve requests.
Description: | Sets the upper limit on the configurable number of threadsper child process |
---|---|
Syntax: | ThreadLimitnumber |
Default: | See usage for details |
Context: | server config |
Status: | MPM |
Module: | event ,worker ,mpm_winnt |
This directive sets the maximum configured value forThreadsPerChild
for the lifetime of the Apache httpd process. Any attempts to change this directive during a restart will be ignored, butThreadsPerChild
can be modified during a restart up to the value of this directive.
Special care must be taken when using this directive. IfThreadLimit
is set to a value much higher thanThreadsPerChild
, extra unused shared memory will be allocated. If bothThreadLimit
andThreadsPerChild
are set to values higher than the system can handle, Apache httpd may not start or the system may become unstable. Do not set the value of this directive any higher than your greatest predicted setting ofThreadsPerChild
for the current run of Apache httpd.
The default value forThreadLimit
is1920
when used withmpm_winnt
and64
when used with the others.
There is a hard limit ofThreadLimit 20000
(orThreadLimit 100000
withevent
,ThreadLimit 15000
withmpm_winnt
) compiled into the server. This is intended to avoid nasty effects caused by typos. To increase it even further past this limit, you will need to modify the value of MAX_THREAD_LIMIT in the mpm source file and rebuild the server.
Description: | Number of threads created by each child process |
---|---|
Syntax: | ThreadsPerChildnumber |
Default: | See usage for details |
Context: | server config |
Status: | MPM |
Module: | event ,worker ,mpm_winnt |
This directive sets the number of threads created by each child process. The child creates these threads at startup and never creates more. If using an MPM likempm_winnt
, where there is only one child process, this number should be high enough to handle the entire load of the server. If using an MPM likeworker
, where there are multiple child processes, thetotal number of threads should be high enough to handle the common load on the server.
The default value forThreadsPerChild
is64
when used withmpm_winnt
and25
when used with the others.
The value ofThreadsPerChild
can not exceed the value ofThreadLimit
. If a higher value is configured, it will be automatically reduced at start-up and a warning will be logged. The relationship between these 2 directives is explained inThreadLimit
.
Description: | The size in bytes of the stack used by threads handlingclient connections |
---|---|
Syntax: | ThreadStackSizesize |
Default: | 65536 on NetWare; varies on other operating systems |
Context: | server config |
Status: | MPM |
Module: | event ,worker ,mpm_winnt ,mpm_netware ,mpmt_os2 |
Compatibility: | Available in Apache HTTP Server 2.1 and later |
TheThreadStackSize
directive sets the size of the stack (for autodata) of threads which handle client connections and call modules to help process those connections. In most cases the operating system default for stack size is reasonable, but there are some conditions where it may need to be adjusted:
ThreadStackSize
to a value higher than the operating system default. This type of adjustment is necessary only if the provider of the third-party module specifies that it is required, or if diagnosis of an Apache httpd crash indicates that the thread stack size was too small.ThreadStackSize
is set to a value lower than the operating system default. This type of adjustment should only be made in a test environment which allows the full set of web server processing to be exercised, as there may be infrequent requests which require more stack to process. The minimum required stack size strongly depends on the modules used, but any change in the web server configuration can invalidate the currentThreadStackSize
setting.ulimit -s
(8MB if unlimited) is used as the default stack size.ThreadStackSize
unless a high number of threads per child process is needed. On some platforms (including Linux), a setting of 128000 is already too low and causes crashes with some common modules.Copyright 2025 The Apache Software Foundation.
Licensed under theApache License, Version 2.0.