php5-fpm-pools.conf.j2 18 KB

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