Apache: Add an option to set the MPM
Supported values are "prefork" (default), "worker" and "event" (experimental in Apache 2.2 but not 2.4).
This commit is contained in:
parent
a07eb262a0
commit
18031e41bb
1 changed files with 25 additions and 2 deletions
|
@ -6,7 +6,7 @@ let
|
||||||
|
|
||||||
mainCfg = config.services.httpd;
|
mainCfg = config.services.httpd;
|
||||||
|
|
||||||
httpd = pkgs.apacheHttpd;
|
httpd = pkgs.apacheHttpd.override { mpm = mainCfg.multiProcessingModule; };
|
||||||
|
|
||||||
getPort = cfg: if cfg.port != 0 then cfg.port else if cfg.enableSSL then 443 else 80;
|
getPort = cfg: if cfg.port != 0 then cfg.port else if cfg.enableSSL then 443 else 80;
|
||||||
|
|
||||||
|
@ -105,10 +105,11 @@ let
|
||||||
# Other modules.
|
# Other modules.
|
||||||
"ext_filter" "include" "log_config" "env" "mime_magic"
|
"ext_filter" "include" "log_config" "env" "mime_magic"
|
||||||
"cern_meta" "expires" "headers" "usertrack" /* "unique_id" */ "setenvif"
|
"cern_meta" "expires" "headers" "usertrack" /* "unique_id" */ "setenvif"
|
||||||
"mime" "dav" "status" "autoindex" "asis" "info" "cgi" "dav_fs"
|
"mime" "dav" "status" "autoindex" "asis" "info" "dav_fs"
|
||||||
"vhost_alias" "negotiation" "dir" "imagemap" "actions" "speling"
|
"vhost_alias" "negotiation" "dir" "imagemap" "actions" "speling"
|
||||||
"userdir" "alias" "rewrite" "proxy" "proxy_http"
|
"userdir" "alias" "rewrite" "proxy" "proxy_http"
|
||||||
]
|
]
|
||||||
|
++ (if mainCfg.multiProcessingModule == "prefork" then [ "cgi" ] else [ "cgid" ])
|
||||||
++ optional enableSSL "ssl"
|
++ optional enableSSL "ssl"
|
||||||
++ extraApacheModules;
|
++ extraApacheModules;
|
||||||
|
|
||||||
|
@ -283,6 +284,11 @@ let
|
||||||
|
|
||||||
PidFile ${mainCfg.stateDir}/httpd.pid
|
PidFile ${mainCfg.stateDir}/httpd.pid
|
||||||
|
|
||||||
|
${optionalString (mainCfg.multiProcessingModule != "prefork") ''
|
||||||
|
# mod_cgid requires this.
|
||||||
|
ScriptSock ${mainCfg.stateDir}/cgisock
|
||||||
|
''}
|
||||||
|
|
||||||
<IfModule prefork.c>
|
<IfModule prefork.c>
|
||||||
MaxClients ${toString mainCfg.maxClients}
|
MaxClients ${toString mainCfg.maxClients}
|
||||||
MaxRequestsPerChild ${toString mainCfg.maxRequestsPerChild}
|
MaxRequestsPerChild ${toString mainCfg.maxRequestsPerChild}
|
||||||
|
@ -484,6 +490,23 @@ in
|
||||||
"Options appended to the PHP configuration file <filename>php.ini</filename>.";
|
"Options appended to the PHP configuration file <filename>php.ini</filename>.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
multiProcessingModule = mkOption {
|
||||||
|
default = "prefork";
|
||||||
|
example = "worker";
|
||||||
|
type = types.uniq types.string;
|
||||||
|
description =
|
||||||
|
''
|
||||||
|
Multi-processing module to be used by Apache. Available
|
||||||
|
modules are <literal>prefork</literal> (the default;
|
||||||
|
handles each request in a separate child process),
|
||||||
|
<literal>worker</literal> (hybrid approach that starts a
|
||||||
|
number of child processes each running a number of
|
||||||
|
threads) and <literal>event</literal> (a recent variant of
|
||||||
|
<literal>worker</literal> that handles persistent
|
||||||
|
connections more efficiently).
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
maxClients = mkOption {
|
maxClients = mkOption {
|
||||||
default = 150;
|
default = 150;
|
||||||
example = 8;
|
example = 8;
|
||||||
|
|
Loading…
Reference in a new issue