From 509e05bd43f370ad3cae81ba3f01a9192d64c38f Mon Sep 17 00:00:00 2001 From: Christoph Date: Mon, 13 Sep 2021 17:51:28 +0200 Subject: [PATCH] Support user settings of some PHP Pool Definitions. --- mod_php_install.sh | 159 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 148 insertions(+), 11 deletions(-) diff --git a/mod_php_install.sh b/mod_php_install.sh index 1d34296..b769ce4 100755 --- a/mod_php_install.sh +++ b/mod_php_install.sh @@ -770,6 +770,137 @@ if $WITH_PHP_FPM_SUPPORT ; then else SET_UMASK=false fi + + + + DEFAULT_FPM_POOL_START_SERVER=15 + DEFAULT_FPM_POOL_MIN_SPARE=6 + DEFAULT_FPM_POOL_MAX_SPARE=24 + DEFAULT_FPM_POOL_MAX_REQUESTS=500 + DEFAULT_FPM_POOL_MAX_CHILDREN=250 + + # If php pool definitions exists on installed php, then take that value + # + if [[ -f "/usr/local/php-${PHP_MAIN_VERSION}/etc/fpm.d/www-${PHP_MAIN_VERSION}.php-fpm.conf" ]] ; then + __pm_start_servers=$(grep -e "^\s*pm.start_servers" "/usr/local/php-${PHP_MAIN_VERSION}/etc/fpm.d/www-${PHP_MAIN_VERSION}.php-fpm.conf" | awk '{print$3}') + if [[ -n "$__pm_start_servers" ]] ; then + DEFAULT_FPM_POOL_START_SERVER=$__pm_start_servers + fi + fi + + if [[ -f "/usr/local/php-${PHP_MAIN_VERSION}/etc/fpm.d/www-${PHP_MAIN_VERSION}.php-fpm.conf" ]] ; then + __pm_min_spare_servers=$(grep -e "^\s*pm.min_spare_servers" "/usr/local/php-${PHP_MAIN_VERSION}/etc/fpm.d/www-${PHP_MAIN_VERSION}.php-fpm.conf" | awk '{print$3}') + if [[ -n "$__pm_min_spare_servers" ]] ; then + DEFAULT_FPM_POOL_MIN_SPARE=$__pm_min_spare_servers + fi + fi + + if [[ -f "/usr/local/php-${PHP_MAIN_VERSION}/etc/fpm.d/www-${PHP_MAIN_VERSION}.php-fpm.conf" ]] ; then + __pm_max_spare_servers=$(grep -e "^\s*pm.max_spare_servers" "/usr/local/php-${PHP_MAIN_VERSION}/etc/fpm.d/www-${PHP_MAIN_VERSION}.php-fpm.conf" | awk '{print$3}') + if [[ -n "$__pm_max_spare_servers" ]] ; then + DEFAULT_FPM_POOL_MAX_SPARE=$__pm_max_spare_servers + fi + fi + + if [[ -f "/usr/local/php-${PHP_MAIN_VERSION}/etc/fpm.d/www-${PHP_MAIN_VERSION}.php-fpm.conf" ]] ; then + __pm_max_requests=$(grep -e "^\s*pm.max_requests" "/usr/local/php-${PHP_MAIN_VERSION}/etc/fpm.d/www-${PHP_MAIN_VERSION}.php-fpm.conf" | awk '{print$3}') + if [[ -n "$__pm_max_requests" ]] ; then + DEFAULT_FPM_POOL_MAX_REQUESTS=$__pm_max_requests + fi + fi + + if [[ -f "/usr/local/php-${PHP_MAIN_VERSION}/etc/fpm.d/www-${PHP_MAIN_VERSION}.php-fpm.conf" ]] ; then + __pm_max_children=$(grep -e "^\s*pm.max_children" "/usr/local/php-${PHP_MAIN_VERSION}/etc/fpm.d/www-${PHP_MAIN_VERSION}.php-fpm.conf" | awk '{print$3}') + if [[ -n "$__pm_max_children" ]] ; then + DEFAULT_FPM_POOL_MAX_CHILDREN=$__pm_max_children + fi + fi + + + + echo "" + echo "" + echo -e "\033[32m--\033[m" + echo "" + echo -e "Some FPM Pool Definitions for php-fpm.conf or included files.." + echo "" + + FPM_POOL_START_SERVER="" + while [[ "X$FPM_POOL_START_SERVER" = "X" ]]; do + echononl "pm.start_servers: [$DEFAULT_FPM_POOL_START_SERVER] " + read FPM_POOL_START_SERVER + if [ "X$FPM_POOL_START_SERVER" = "X" ]; then + FPM_POOL_START_SERVER=$DEFAULT_FPM_POOL_START_SERVER + break + fi + if ! is_int $FPM_POOL_START_SERVER ; then + warn "Wrong value for pm.start_servers was given (mus be an integer). Reenter again" + FPM_POOL_START_SERVER="" + continue + fi + done + + FPM_POOL_MIN_SPARE="" + while [[ "X$FPM_POOL_MIN_SPARE" = "X" ]]; do + echononl "pm.min_spare_servers: [$DEFAULT_FPM_POOL_MIN_SPARE] " + read FPM_POOL_MIN_SPARE + if [ "X$FPM_POOL_MIN_SPARE" = "X" ]; then + FPM_POOL_MIN_SPARE=$DEFAULT_FPM_POOL_MIN_SPARE + break + fi + if ! is_int $FPM_POOL_MIN_SPARE ; then + warn "Wrong value for pm.min_spare_servers was given (mus be an integer). Reenter again" + FPM_POOL_MIN_SPARE="" + continue + fi + done + + FPM_POOL_MAX_SPARE="" + while [[ "X$FPM_POOL_MAX_SPARE" = "X" ]]; do + echononl "pm.max_spare_servers: [$DEFAULT_FPM_POOL_MAX_SPARE] " + read FPM_POOL_MAX_SPARE + if [ "X$FPM_POOL_MAX_SPARE" = "X" ]; then + FPM_POOL_MAX_SPARE=$DEFAULT_FPM_POOL_MAX_SPARE + break + fi + if ! is_int $FPM_POOL_MAX_SPARE ; then + warn "Wrong value for pm.max_spare_servers was given (mus be an integer). Reenter again" + FPM_POOL_MAX_SPARE="" + continue + fi + done + + FPM_POOL_MAX_REQUESTS="" + while [[ "X$FPM_POOL_MAX_REQUESTS" = "X" ]]; do + echononl "pm.max_requests: [$DEFAULT_FPM_POOL_MAX_REQUESTS] " + read FPM_POOL_MAX_REQUESTS + if [ "X$FPM_POOL_MAX_REQUESTS" = "X" ]; then + FPM_POOL_MAX_REQUESTS=$DEFAULT_FPM_POOL_MAX_REQUESTS + break + fi + if ! is_int $FPM_POOL_MAX_REQUESTS ; then + warn "Wrong value for pm.max_request was given (mus be an integer). Reenter again" + FPM_POOL_MAX_REQUESTS="" + continue + fi + done + + FPM_POOL_MAX_CHILDREN="" + while [[ "X$FPM_POOL_MAX_CHILDREN" = "X" ]]; do + echononl "pm.max_requests: [$DEFAULT_FPM_POOL_MAX_CHILDREN] " + read FPM_POOL_MAX_CHILDREN + if [ "X$FPM_POOL_MAX_CHILDREN" = "X" ]; then + FPM_POOL_MAX_CHILDREN=$DEFAULT_FPM_POOL_MAX_CHILDREN + break + fi + if ! is_int $FPM_POOL_MAX_CHILDREN ; then + warn "Wrong value for pm.max_request was given (mus be an integer). Reenter again" + FPM_POOL_MAX_CHILDREN="" + continue + fi + done + + fi if $WITH_PHP_FPM_SUPPORT && $WITH_MOD_PHP ; then @@ -801,6 +932,7 @@ if $WITH_PHP_FPM_SUPPORT && $WITH_MOD_PHP ; then fi fi + if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 9 ]] ; then FPM_PID_FILE=/run/php-${PHP_MAIN_VERSION}-fpm.pid else @@ -824,12 +956,6 @@ FPM_DEFAULT_POOL_LISTEN_GROUP=$HTTPD_GROUP FPM_DEFAULT_POOL_LISTEN_MODE=0660 FPM_DEFAULT_POOL_PM=dynamic -FPM_DEFAULT_POOL_MAX_CHILDREN=250 -FPM_DEFAULT_POOL_START_SERVER=5 -FPM_DEFAULT_POOL_MIN_SPARE=5 -FPM_DEFAULT_POOL_MAX_SPARE=10 - -FPM_DEFAULT_POOL_MAX_REQUESTS=500 FPM_DEFAULT_POOL_STATUS_PATH="/status-${PHP_MAIN_VERSION}" FPM_DEFAULT_POOL_PING_PATH="/ping-${PHP_MAIN_VERSION}" @@ -1083,6 +1209,17 @@ if $WITH_PHP_FPM_SUPPORT ; then echo " $(basename "$_file")" done fi + + echo "" + echo "PHP FPM Pool Definitions (php-fpm.conf or included files)" + echo " pm.start_servers..............: $FPM_POOL_START_SERVER" + echo " pm.min_spare_servers..........: $FPM_POOL_MIN_SPARE" + echo " pm.max_spare_servers..........: $FPM_POOL_MAX_SPARE" + echo " pm.max_children...............: $FPM_POOL_MAX_CHILDREN" + echo " pm.max_requests...............: $FPM_POOL_MAX_REQUESTS" + + + fi if [[ $PHP_MAJOR_VERSION -ge 7 ]]; then echo "" @@ -2874,22 +3011,22 @@ pm = $FPM_DEFAULT_POOL_PM ; forget to tweak pm.* to fit your needs. ; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' ; Note: This value is mandatory. -pm.max_children = $FPM_DEFAULT_POOL_MAX_CHILDREN +pm.max_children = $FPM_POOL_MAX_CHILDREN ; The number of child processes created on startup. ; Note: Used only when pm is set to 'dynamic' ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 -pm.start_servers = $FPM_DEFAULT_POOL_START_SERVER +pm.start_servers = $FPM_POOL_START_SERVER ; The desired minimum number of idle server processes. ; Note: Used only when pm is set to 'dynamic' ; Note: Mandatory when pm is set to 'dynamic' -pm.min_spare_servers = $FPM_DEFAULT_POOL_MIN_SPARE +pm.min_spare_servers = $FPM_POOL_MIN_SPARE ; The desired maximum number of idle server processes. ; Note: Used only when pm is set to 'dynamic' ; Note: Mandatory when pm is set to 'dynamic' -pm.max_spare_servers = $FPM_DEFAULT_POOL_MAX_SPARE +pm.max_spare_servers = $FPM_POOL_MAX_SPARE ; The number of seconds after which an idle process will be killed. ; Note: Used only when pm is set to 'ondemand' @@ -2900,7 +3037,7 @@ pm.max_spare_servers = $FPM_DEFAULT_POOL_MAX_SPARE ; 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. ; Default Value: 0 -pm.max_requests = $FPM_DEFAULT_POOL_MAX_REQUESTS +pm.max_requests = $FPM_POOL_MAX_REQUESTS ; The URI to view the FPM status page. If this value is not set, no URI will be ; recognized as a status page. It shows the following informations: