php-fpm-pools.conf.j2 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. {% if ansible_controlled is defined and ansible_controlled != "" %}
  2. ;
  3. ; {{ ansible_controlled }}
  4. ;
  5. {% endif %}
  6. ;;;;;;;;;;;;;;;;;;;;;;;;
  7. ; FPM Pool Definitions ;·
  8. ;;;;;;;;;;;;;;;;;;;;;;;;
  9. ; Multiple pools of child processes may be started with different listening
  10. ; ports and different management options. The name of the pool will be
  11. ; used in logs and stats. There is no limitation on the number of pools which
  12. ; FPM can handle. Your system will tell you anyway :)
  13. ; Start a new pool named 'www'.
  14. ; the variable $pool can be used in any directive and will be replaced by the
  15. ; pool name ('www' here)
  16. {% for pool in fpm_pools %}
  17. {% for num in range(0, fpm_pools[pool].count, 1) %}
  18. [{{ pool }}{{ num }}]
  19. ; Per pool prefix
  20. ; It only applies on the following directives:
  21. ; - 'access.log'
  22. ; - 'slowlog'
  23. ; - 'listen' (unixsocket)
  24. ; - 'chroot'
  25. ; - 'chdir'
  26. ; - 'php_values'
  27. ; - 'php_admin_values'
  28. ; When not set, the global prefix (or /usr) applies instead.
  29. ; Note: This directive can also be relative to the global prefix.
  30. ; Default Value: none
  31. ;prefix = /path/to/pools/$pool
  32. ; Unix user/group of processes
  33. ; Note: The user is mandatory. If the group is not set, the default user's group
  34. ; will be used.
  35. user = {% if fpm_pools[pool].user is defined %}{{ fpm_pools[pool].user }}{% else %}{{ fpm_user }}{% endif %}
  36. group = {% if fpm_pools[pool].group is defined %}{{ fpm_pools[pool].group }}{% else %}{{ fpm_group }}{% endif %}
  37. ; The address on which to accept FastCGI requests.
  38. ; Valid syntaxes are:
  39. ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
  40. ; a specific port;
  41. ; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
  42. ; a specific port;
  43. ; 'port' - to listen on a TCP socket to all addresses
  44. ; (IPv6 and IPv4-mapped) on a specific port;
  45. ; '/path/to/unix/socket' - to listen on a unix socket.
  46. ; Note: This value is mandatory.
  47. listen = /run/php/php{{ php_version }}-fpm-pool-$pool.sock
  48. ; Set listen(2) backlog.
  49. ; Default Value: 511 (-1 on FreeBSD and OpenBSD)
  50. listen.backlog = 8192
  51. ; Set permissions for unix socket, if one is used. In Linux, read/write
  52. ; permissions must be set in order to allow connections from a web server. Many
  53. ; BSD-derived systems allow connections regardless of permissions.
  54. ; Default Values: user and group are set as the running user
  55. ; mode is set to 0660
  56. listen.owner = www-data
  57. listen.group = www-data
  58. listen.mode = 0660
  59. ; When POSIX Access Control Lists are supported you can set them using
  60. ; these options, value is a comma separated list of user/group names.
  61. ; When set, listen.owner and listen.group are ignored
  62. ;listen.acl_users =
  63. ;listen.acl_groups =
  64. ; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
  65. ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
  66. ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
  67. ; must be separated by a comma. If this value is left blank, connections will be
  68. ; accepted from any ip address.
  69. ; Default Value: any
  70. ;listen.allowed_clients = 127.0.0.1
  71. ; Specify the nice(2) priority to apply to the pool processes (only if set)
  72. ; The value can vary from -19 (highest priority) to 20 (lower priority)
  73. ; Note: - It will only work if the FPM master process is launched as root
  74. ; - The pool processes will inherit the master process priority
  75. ; unless it specified otherwise
  76. ; Default Value: no set
  77. ; process.priority = -19
  78. ; Choose how the process manager will control the number of child processes.
  79. ; Possible Values:
  80. ; static - a fixed number (pm.max_children) of child processes;
  81. ; dynamic - the number of child processes are set dynamically based on the
  82. ; following directives. With this process management, there will be
  83. ; always at least 1 children.
  84. ; pm.max_children - the maximum number of children that can
  85. ; be alive at the same time.
  86. ; pm.start_servers - the number of children created on startup.
  87. ; pm.min_spare_servers - the minimum number of children in 'idle'
  88. ; state (waiting to process). If the number
  89. ; of 'idle' processes is less than this
  90. ; number then some children will be created.
  91. ; pm.max_spare_servers - the maximum number of children in 'idle'
  92. ; state (waiting to process). If the number
  93. ; of 'idle' processes is greater than this
  94. ; number then some children will be killed.
  95. ; ondemand - no children are created at startup. Children will be forked when
  96. ; new requests will connect. The following parameter are used:
  97. ; pm.max_children - the maximum number of children that
  98. ; can be alive at the same time.
  99. ; pm.process_idle_timeout - The number of seconds after which
  100. ; an idle process will be killed.
  101. ; Note: This value is mandatory.
  102. pm = {% if fpm_pools[pool].pm is defined %}{{ fpm_pools[pool].pm }}{% else %}dynamic{% endif %}
  103. ; The number of child processes to be created when pm is set to 'static' and the
  104. ; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
  105. ; This value sets the limit on the number of simultaneous requests that will be
  106. ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
  107. ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
  108. ; CGI. The below defaults are based on a server without much resources. Don't
  109. ; forget to tweak pm.* to fit your needs.
  110. ; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
  111. ; Note: This value is mandatory.
  112. pm.max_children = {% if fpm_pools[pool].max_children is defined %}{{ fpm_pools[pool].max_children }}{% else %}{{ fpm_max_children }}{% endif %}
  113. ; The number of child processes created on startup.
  114. ; Note: Used only when pm is set to 'dynamic'
  115. ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
  116. pm.start_servers = {% if fpm_pools[pool].start_servers is defined %}{{ fpm_pools[pool].start_servers }}{% else %}{{ fpm_start_servers }}{% endif %}
  117. ; The desired minimum number of idle server processes.
  118. ; Note: Used only when pm is set to 'dynamic'
  119. ; Note: Mandatory when pm is set to 'dynamic'
  120. pm.min_spare_servers = {% if fpm_pools[pool].min_spare_servers is defined %}{{ fpm_pools[pool].min_spare_servers }}{% else %}{{ fpm_min_spare_servers }}{% endif %}
  121. ; The desired maximum number of idle server processes.
  122. ; Note: Used only when pm is set to 'dynamic'
  123. ; Note: Mandatory when pm is set to 'dynamic'
  124. pm.max_spare_servers = {% if fpm_pools[pool].max_spare_servers is defined %}{{ fpm_pools[pool].max_spare_servers }}{% else %}{{ fpm_max_spare_servers }}{% endif %}
  125. ; The number of seconds after which an idle process will be killed.
  126. ; Note: Used only when pm is set to 'ondemand'
  127. ; Default Value: 10s
  128. ;pm.process_idle_timeout = 10s;
  129. ; The number of requests each child process should execute before respawning.
  130. ; This can be useful to work around memory leaks in 3rd party libraries. For
  131. ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
  132. ; Default Value: 0
  133. pm.max_requests = {% if fpm_pools[pool].max_requests is defined %}{{ fpm_pools[pool].max_requests }}{% else %}200{% endif %}
  134. ; The URI to view the FPM status page. If this value is not set, no URI will be
  135. ; recognized as a status page. It shows the following informations:
  136. ; pool - the name of the pool;
  137. ; process manager - static, dynamic or ondemand;
  138. ; start time - the date and time FPM has started;
  139. ; start since - number of seconds since FPM has started;
  140. ; accepted conn - the number of request accepted by the pool;
  141. ; listen queue - the number of request in the queue of pending
  142. ; connections (see backlog in listen(2));
  143. ; max listen queue - the maximum number of requests in the queue
  144. ; of pending connections since FPM has started;
  145. ; listen queue len - the size of the socket queue of pending connections;
  146. ; idle processes - the number of idle processes;
  147. ; active processes - the number of active processes;
  148. ; total processes - the number of idle + active processes;
  149. ; max active processes - the maximum number of active processes since FPM
  150. ; has started;
  151. ; max children reached - number of times, the process limit has been reached,
  152. ; when pm tries to start more children (works only for
  153. ; pm 'dynamic' and 'ondemand');
  154. ; Value are updated in real time.
  155. ; Example output:
  156. ; pool: www
  157. ; process manager: static
  158. ; start time: 01/Jul/2011:17:53:49 +0200
  159. ; start since: 62636
  160. ; accepted conn: 190460
  161. ; listen queue: 0
  162. ; max listen queue: 1
  163. ; listen queue len: 42
  164. ; idle processes: 4
  165. ; active processes: 11
  166. ; total processes: 15
  167. ; max active processes: 12
  168. ; max children reached: 0
  169. ;
  170. ; By default the status page output is formatted as text/plain. Passing either
  171. ; 'html', 'xml' or 'json' in the query string will return the corresponding
  172. ; output syntax. Example:
  173. ; http://www.foo.bar/status
  174. ; http://www.foo.bar/status?json
  175. ; http://www.foo.bar/status?html
  176. ; http://www.foo.bar/status?xml
  177. ;
  178. ; By default the status page only outputs short status. Passing 'full' in the
  179. ; query string will also return status for each pool process.
  180. ; Example:
  181. ; http://www.foo.bar/status?full
  182. ; http://www.foo.bar/status?json&full
  183. ; http://www.foo.bar/status?html&full
  184. ; http://www.foo.bar/status?xml&full
  185. ; The Full status returns for each process:
  186. ; pid - the PID of the process;
  187. ; state - the state of the process (Idle, Running, ...);
  188. ; start time - the date and time the process has started;
  189. ; start since - the number of seconds since the process has started;
  190. ; requests - the number of requests the process has served;
  191. ; request duration - the duration in µs of the requests;
  192. ; request method - the request method (GET, POST, ...);
  193. ; request URI - the request URI with the query string;
  194. ; content length - the content length of the request (only with POST);
  195. ; user - the user (PHP_AUTH_USER) (or '-' if not set);
  196. ; script - the main script called (or '-' if not set);
  197. ; last request cpu - the %cpu the last request consumed
  198. ; it's always 0 if the process is not in Idle state
  199. ; because CPU calculation is done when the request
  200. ; processing has terminated;
  201. ; last request memory - the max amount of memory the last request consumed
  202. ; it's always 0 if the process is not in Idle state
  203. ; because memory calculation is done when the request
  204. ; processing has terminated;
  205. ; If the process is in Idle state, then informations are related to the
  206. ; last request the process has served. Otherwise informations are related to
  207. ; the current request being served.
  208. ; Example output:
  209. ; ************************
  210. ; pid: 31330
  211. ; state: Running
  212. ; start time: 01/Jul/2011:17:53:49 +0200
  213. ; start since: 63087
  214. ; requests: 12808
  215. ; request duration: 1250261
  216. ; request method: GET
  217. ; request URI: /test_mem.php?N=10000
  218. ; content length: 0
  219. ; user: -
  220. ; script: /home/fat/web/docs/php/test_mem.php
  221. ; last request cpu: 0.00
  222. ; last request memory: 0
  223. ;
  224. ; Note: There is a real-time FPM status monitoring sample web page available
  225. ; It's available in: /usr/share/php/{{ php_version }}/fpm/status.html
  226. ;
  227. ; Note: The value must start with a leading slash (/). The value can be
  228. ; anything, but it may not be a good idea to use the .php extension or it
  229. ; may conflict with a real PHP file.
  230. ; Default Value: not set
  231. ;pm.status_path = /status
  232. ; The ping URI to call the monitoring page of FPM. If this value is not set, no
  233. ; URI will be recognized as a ping page. This could be used to test from outside
  234. ; that FPM is alive and responding, or to
  235. ; - create a graph of FPM availability (rrd or such);
  236. ; - remove a server from a group if it is not responding (load balancing);
  237. ; - trigger alerts for the operating team (24/7).
  238. ; Note: The value must start with a leading slash (/). The value can be
  239. ; anything, but it may not be a good idea to use the .php extension or it
  240. ; may conflict with a real PHP file.
  241. ; Default Value: not set
  242. ;ping.path = /ping
  243. ; This directive may be used to customize the response of a ping request. The
  244. ; response is formatted as text/plain with a 200 response code.
  245. ; Default Value: pong
  246. ;ping.response = pong
  247. ; The access log file
  248. ; Default: not set
  249. ;access.log = log/$pool.access.log
  250. ; The access log format.
  251. ; The following syntax is allowed
  252. ; %%: the '%' character
  253. ; %C: %CPU used by the request
  254. ; it can accept the following format:
  255. ; - %{user}C for user CPU only
  256. ; - %{system}C for system CPU only
  257. ; - %{total}C for user + system CPU (default)
  258. ; %d: time taken to serve the request
  259. ; it can accept the following format:
  260. ; - %{seconds}d (default)
  261. ; - %{miliseconds}d
  262. ; - %{mili}d
  263. ; - %{microseconds}d
  264. ; - %{micro}d
  265. ; %e: an environment variable (same as $_ENV or $_SERVER)
  266. ; it must be associated with embraces to specify the name of the env
  267. ; variable. Some exemples:
  268. ; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
  269. ; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
  270. ; %f: script filename
  271. ; %l: content-length of the request (for POST request only)
  272. ; %m: request method
  273. ; %M: peak of memory allocated by PHP
  274. ; it can accept the following format:
  275. ; - %{bytes}M (default)
  276. ; - %{kilobytes}M
  277. ; - %{kilo}M
  278. ; - %{megabytes}M
  279. ; - %{mega}M
  280. ; %n: pool name
  281. ; %o: output header
  282. ; it must be associated with embraces to specify the name of the header:
  283. ; - %{Content-Type}o
  284. ; - %{X-Powered-By}o
  285. ; - %{Transfert-Encoding}o
  286. ; - ....
  287. ; %p: PID of the child that serviced the request
  288. ; %P: PID of the parent of the child that serviced the request
  289. ; %q: the query string
  290. ; %Q: the '?' character if query string exists
  291. ; %r: the request URI (without the query string, see %q and %Q)
  292. ; %R: remote IP address
  293. ; %s: status (response code)
  294. ; %t: server time the request was received
  295. ; it can accept a strftime(3) format:
  296. ; %d/%b/%Y:%H:%M:%S %z (default)
  297. ; The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag
  298. ; e.g. for a ISO8601 formatted timestring, use: %{ %Y-%m-%dT%H:%M:%S%z}t
  299. ; %T: time the log has been written (the request has finished)
  300. ; it can accept a strftime(3) format:
  301. ; %d/%b/%Y:%H:%M:%S %z (default)
  302. ; The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag
  303. ; e.g. for a ISO8601 formatted timestring, use: %{ %Y-%m-%dT%H:%M:%S%z}t
  304. ; %u: remote user
  305. ;
  306. ; Default: "%R - %u %t \"%m %r\" %s"
  307. ;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
  308. ; The log file for slow requests
  309. ; Default Value: not set
  310. ; Note: slowlog is mandatory if request_slowlog_timeout is set
  311. ;slowlog = log/$pool.log.slow
  312. ; The timeout for serving a single request after which a PHP backtrace will be
  313. ; dumped to the 'slowlog' file. A value of '0s' means 'off'.
  314. ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
  315. ; Default Value: 0
  316. ;request_slowlog_timeout = 0
  317. ; The timeout for serving a single request after which the worker process will
  318. ; be killed. This option should be used when the 'max_execution_time' ini option
  319. ; does not stop script execution for some reason. A value of '0' means 'off'.
  320. ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
  321. ; Default Value: 0
  322. ;request_terminate_timeout = 0
  323. ; Set open file descriptor rlimit.
  324. ; Default Value: system defined value
  325. rlimit_files = 262144
  326. ; Set max core size rlimit.
  327. ; Possible Values: 'unlimited' or an integer greater or equal to 0
  328. ; Default Value: system defined value
  329. ;rlimit_core = 0
  330. ; Chroot to this directory at the start. This value must be defined as an
  331. ; absolute path. When this value is not set, chroot is not used.
  332. ; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
  333. ; of its subdirectories. If the pool prefix is not set, the global prefix
  334. ; will be used instead.
  335. ; Note: chrooting is a great security feature and should be used whenever
  336. ; possible. However, all PHP paths will be relative to the chroot
  337. ; (error_log, sessions.save_path, ...).
  338. ; Default Value: not set
  339. ;chroot =
  340. ; Chdir to this directory at the start.
  341. ; Note: relative path can be used.
  342. ; Default Value: current directory or / when chroot
  343. ;chdir = /var/www
  344. ; Redirect worker stdout and stderr into main error log. If not set, stdout and
  345. ; stderr will be redirected to /dev/null according to FastCGI specs.
  346. ; Note: on highloaded environement, this can cause some delay in the page
  347. ; process time (several ms).
  348. ; Default Value: no
  349. catch_workers_output = yes
  350. ; Limits the extensions of the main script FPM will allow to parse. This can
  351. ; prevent configuration mistakes on the web server side. You should only limit
  352. ; FPM to .php extensions to prevent malicious users to use other extensions to
  353. ; exectute php code.
  354. ; Note: set an empty value to allow all extensions.
  355. ; Default Value: .php
  356. ;security.limit_extensions = .php .php3 .php4 .php5 .php7
  357. ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
  358. ; the current environment.
  359. ; Default Value: clean env
  360. ;env[HOSTNAME] = $HOSTNAME
  361. ;env[PATH] = /usr/local/bin:/usr/bin:/bin
  362. ;env[TMP] = /tmp
  363. ;env[TMPDIR] = /tmp
  364. ;env[TEMP] = /tmp
  365. ; Additional php.ini defines, specific to this pool of workers. These settings
  366. ; overwrite the values previously defined in the php.ini. The directives are the
  367. ; same as the PHP SAPI:
  368. ; php_value/php_flag - you can set classic ini defines which can
  369. ; be overwritten from PHP call 'ini_set'.
  370. ; php_admin_value/php_admin_flag - these directives won't be overwritten by
  371. ; PHP call 'ini_set'
  372. ; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
  373. ; Defining 'extension' will load the corresponding shared extension from
  374. ; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
  375. ; overwrite previously defined php.ini values, but will append the new value
  376. ; instead.
  377. ; Note: path INI options can be relative and will be expanded with the prefix
  378. ; (pool, global or /usr)
  379. ; Default Value: nothing is defined by default except the values in php.ini and
  380. ; specified at startup with the -d argument
  381. ;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
  382. ;php_flag[display_errors] = off
  383. ;php_admin_value[error_log] = /var/log/fpm-php.www.log
  384. ;php_admin_flag[log_errors] = on
  385. ;php_admin_value[memory_limit] = 32M
  386. php_admin_flag[cgi.fix_pathinfo] = on
  387. {% endfor %}
  388. {% endfor %}
  389. ; vim: ft=dosini