php-fpm-custom.conf.j2 21 KB

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