library/roles/php-fpm: Set defaults when possible into the php-fpm-pool template.

This commit is contained in:
Andrea Dell'Amico 2016-10-24 18:03:29 +02:00
parent 02e4941b56
commit bc4ce78e31
2 changed files with 29 additions and 47 deletions

View File

@ -43,9 +43,9 @@ phpfpm_default_listen: "127.0.0.1:9000"
phpfpm_default_allowed_clients: "127.0.0.1" phpfpm_default_allowed_clients: "127.0.0.1"
phpfpm_default_pm: "dynamic" phpfpm_default_pm: "dynamic"
phpfpm_default_pm_max_children: "50" phpfpm_default_pm_max_children: "50"
phpfpm_default_pm_start_servers: "3" phpfpm_default_pm_start_servers: "8"
phpfpm_default_pm_min_spare_servers: "1" phpfpm_default_pm_min_spare_servers: "5"
phpfpm_default_pm_max_spare_servers: "10" phpfpm_default_pm_max_spare_servers: "12"
phpfpm_default_pm_max_requests: "10000" phpfpm_default_pm_max_requests: "10000"
phpfpm_default_pm_status_enabled: False phpfpm_default_pm_status_enabled: False
phpfpm_default_pm_status_path: "/status" phpfpm_default_pm_status_path: "/status"
@ -55,9 +55,9 @@ phpfpm_default_ping_response: '{{ phpfpm_default_pool_name }}'
phpfpm_default_display_errors: "off" phpfpm_default_display_errors: "off"
phpfpm_default_log_errors: "on" phpfpm_default_log_errors: "on"
phpfpm_default_memory_limit: "64M" phpfpm_default_memory_limit: "64M"
phpfpm_default_request_terminate_timeout: "60s" phpfpm_default_request_terminate_timeout: "240s"
phpfpm_default_slowlog_timeout: "20s" phpfpm_default_slowlog_timeout: "20s"
phpfpm_default_rlimit_files: "1024" phpfpm_default_rlimit_files: "4096"
phpfpm_default_extensions: ".php" phpfpm_default_extensions: ".php"
phpfpm_default_context: '/' phpfpm_default_context: '/'
phpfpm_default_session_handler: 'files' phpfpm_default_session_handler: 'files'

View File

@ -1,5 +1,5 @@
; Start a new pool named 'www'. ; Start a new pool named 'www'.
[{{ item.pool_name }}] [{{ item.pool_name | default('www') }}]
; The address on which to accept FastCGI requests. ; The address on which to accept FastCGI requests.
; Valid syntaxes are: ; Valid syntaxes are:
@ -9,7 +9,7 @@
; specific port; ; specific port;
; '/path/to/unix/socket' - to listen on a unix socket. ; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory. ; Note: This value is mandatory.
listen = {{ item.listen }} listen = {{ item.listen | default ('127.0.0.1:9000') }}
; Set listen(2) backlog. A value of '-1' means unlimited. ; Set listen(2) backlog. A value of '-1' means unlimited.
; Default Value: -1 ; Default Value: -1
@ -21,7 +21,7 @@ listen = {{ item.listen }}
; must be separated by a comma. If this value is left blank, connections will be ; must be separated by a comma. If this value is left blank, connections will be
; accepted from any ip address. ; accepted from any ip address.
; Default Value: any ; Default Value: any
listen.allowed_clients = {{ item.allowed_clients }} listen.allowed_clients = {{ item.allowed_clients | default ('127.0.0.1') }}
; Set permissions for unix socket, if one is used. In Linux, read/write ; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many ; permissions must be set in order to allow connections from a web server. Many
@ -36,9 +36,9 @@ listen.allowed_clients = {{ item.allowed_clients }}
; Note: The user is mandatory. If the group is not set, the default user's group ; Note: The user is mandatory. If the group is not set, the default user's group
; will be used. ; will be used.
; RPM: apache Choosed to be able to access some dir as httpd ; RPM: apache Choosed to be able to access some dir as httpd
user = {{ item.user }} user = {{ item.user | default('www-data') }}
; RPM: Keep a group allowed to write in log dir. ; RPM: Keep a group allowed to write in log dir.
group = {{ item.group }} group = {{ item.group | default('www-data') }}
; Choose how the process manager will control the number of child processes. ; Choose how the process manager will control the number of child processes.
; Possible Values: ; Possible Values:
@ -57,7 +57,7 @@ group = {{ item.group }}
; of 'idle' processes is greater than this ; of 'idle' processes is greater than this
; number then some children will be killed. ; number then some children will be killed.
; Note: This value is mandatory. ; Note: This value is mandatory.
pm = {{ item.pm }} pm = {{ item.pm | default('dynamic') }}
; The number of child processes to be created when pm is set to 'static' and the ; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes to be created when pm is set to 'dynamic'. ; maximum number of child processes to be created when pm is set to 'dynamic'.
@ -67,28 +67,28 @@ pm = {{ item.pm }}
; CGI. ; CGI.
; Note: Used when pm is set to either 'static' or 'dynamic' ; Note: Used when pm is set to either 'static' or 'dynamic'
; Note: This value is mandatory. ; Note: This value is mandatory.
pm.max_children = {{ item.pm_max_children }} pm.max_children = {{ item.pm_max_children | default('50') }}
; The number of child processes created on startup. ; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic' ; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
pm.start_servers = {{ item.pm_start_servers }} pm.start_servers = {{ item.pm_start_servers | default('3') }}
; The desired minimum number of idle server processes. ; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic' ; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic' ; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = {{ item.pm_min_spare }} pm.min_spare_servers = {{ item.pm_min_spare | default('1') }}
; The desired maximum number of idle server processes. ; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic' ; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic' ; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = {{ item.pm_max_spare }} pm.max_spare_servers = {{ item.pm_max_spare | default('10') }}
; The number of requests each child process should execute before respawning. ; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For ; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0 ; Default Value: 0
pm.max_requests = {{ item.pm_max_requests }} pm.max_requests = {{ item.pm_max_requests | default('10000') }}
; The URI to view the FPM status page. If this value is not set, no URI will be ; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. By default, the status page shows the following ; recognized as a status page. By default, the status page shows the following
@ -119,7 +119,7 @@ pm.max_requests = {{ item.pm_max_requests }}
; may conflict with a real PHP file. ; may conflict with a real PHP file.
; Default Value: not set ; Default Value: not set
{% if item.pm_status_enabled %} {% if item.pm_status_enabled %}
pm.status_path = {{ item.pm_status_path }} pm.status_path = {{ item.pm_status_path | default('/status') }}
{% endif %} {% endif %}
; The ping URI to call the monitoring page of FPM. If this value is not set, no ; The ping URI to call the monitoring page of FPM. If this value is not set, no
@ -133,14 +133,14 @@ pm.status_path = {{ item.pm_status_path }}
; may conflict with a real PHP file. ; may conflict with a real PHP file.
; Default Value: not set ; Default Value: not set
{% if item.ping_enabled %} {% if item.ping_enabled %}
ping.path = {{ item.ping_path }} ping.path = {{ item.ping_path | default('/ping') }}
{% endif %} {% endif %}
; This directive may be used to customize the response of a ping request. The ; This directive may be used to customize the response of a ping request. The
; response is formatted as text/plain with a 200 response code. ; response is formatted as text/plain with a 200 response code.
; Default Value: pong ; Default Value: pong
{% if item.ping_enabled %} {% if item.ping_enabled %}
ping.response = {{ item.ping_response }} ping.response = {{ item.ping_response | default('www') }}
{% endif %} {% endif %}
access.log = /var/log/php-fpm/$pool-access.log access.log = /var/log/php-fpm/$pool-access.log
@ -205,17 +205,13 @@ access.log = /var/log/php-fpm/$pool-access.log
; does not stop script execution for some reason. A value of '0' means 'off'. ; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0 ; Default Value: 0
{% if item.req_term_timeout is defined %} request_terminate_timeout = {{ item.req_term_timeout | default('240s') }}
request_terminate_timeout = {{ item.req_term_timeout }}
{% else %}
request_terminate_timeout = {{ phpfpm_default_request_terminate_timeout }}
{% endif %}
; The timeout for serving a single request after which a PHP backtrace will be ; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'. ; dumped to the 'slowlog' file. A value of '0s' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0 ; Default Value: 0
request_slowlog_timeout = {{ item.slowlog_timeout }} request_slowlog_timeout = {{ item.slowlog_timeout | default('20s') }}
; The log file for slow requests ; The log file for slow requests
; Default Value: not set ; Default Value: not set
@ -224,7 +220,7 @@ slowlog = /var/log/php-fpm/$pool-slow.log
; Set open file descriptor rlimit. ; Set open file descriptor rlimit.
; Default Value: system defined value ; Default Value: system defined value
rlimit_files = {{ item.rlimit_files }} rlimit_files = {{ item.rlimit_files | default('4096') }}
; Set max core size rlimit. ; Set max core size rlimit.
; Possible Values: 'unlimited' or an integer greater or equal to 0 ; Possible Values: 'unlimited' or an integer greater or equal to 0
@ -254,7 +250,7 @@ catch_workers_output = yes
; exectute php code. ; exectute php code.
; Note: set an empty value to allow all extensions. ; Note: set an empty value to allow all extensions.
; Default Value: .php ; Default Value: .php
security.limit_extensions = {{ item.php_extensions }} security.limit_extensions = {{ item.php_extensions | default('.php') }}
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment. ; the current environment.
@ -282,28 +278,14 @@ security.limit_extensions = {{ item.php_extensions }}
; Default Value: nothing is defined by default except the values in php.ini and ; Default Value: nothing is defined by default except the values in php.ini and
; specified at startup with the -d argument ; specified at startup with the -d argument
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com ;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
php_flag[display_errors] = {{ item.display_errors }} php_flag[display_errors] = {{ item.display_errors | default('off') }}
php_admin_value[error_log] = {{ phpfpm_logdir }}/$pool-error.log php_admin_value[error_log] = {{ phpfpm_logdir }}/$pool-error.log
php_admin_flag[log_errors] = {{ item.log_errors }} php_admin_flag[log_errors] = {{ item.log_errors | default('on') }}
php_admin_value[memory_limit] = {{ item.memory_limit }} php_admin_value[memory_limit] = {{ item.memory_limit | default('64M') }}
{% if item.upload_max_filesize is defined %} php_admin_value[upload_max_filesize] = {{ item.upload_max_filesize | default('100M') }}
php_admin_value[upload_max_filesize] = {{ item.upload_max_filesize }}
{% endif %}
; Set session path to a directory owned by process user ; Set session path to a directory owned by process user
{% if item.session_save_handler is defined %} php_value[session.save_handler] = '{{ item.session_save_handler | default('files') }}'
php_value[session.save_handler] = '{{ item.session_save_handler }}' php_value[session.save_path] = '{{ item.session_save_path | default('/var/lib/php/www') }}'
{% else %}
php_value[session.save_handler] = '{{ phpfpm_default_session_handler }}'
{% endif %}
{% if item.session_save_path is defined %}
php_value[session.save_path] = '{{ item.session_save_path }}'
{% else %}
{% if phpfpm_session_save_path is defined %}
php_value[session.save_path] = '{{ phpfpm_session_save_path }}'
{% else %}
php_value[session.save_path] = '{{ phpfpm_default_session_prefix }}/{{ item.pool_name }}'
{% endif %}
{% endif %}
{% if item.define_custom_variables is defined and item.define_custom_variables %} {% if item.define_custom_variables is defined and item.define_custom_variables %}
{% for php_var in phpfpm_php_variables %} {% for php_var in phpfpm_php_variables %}
php_value[{{ php_var.prop }}] = {{ php_var.value }} php_value[{{ php_var.prop }}] = {{ php_var.value }}