diff --git a/lib.sh b/lib.sh index f4138aff34..5b50e09cf8 100644 --- a/lib.sh +++ b/lib.sh @@ -86,8 +86,9 @@ HTTPS_CONF="/etc/apache2/sites-available/$SUBDOMAIN.conf" HTTP2_CONF="/etc/apache2/mods-available/http2.conf" # PHP-FPM PHPVER=7.2 -PHP_INI=/etc/php/$PHPVER/fpm/php.ini -PHP_POOL_DIR=/etc/php/$PHPVER/fpm/pool.d +PHP_FPM_DIR=/etc/php/$PHPVER/fpm +PHP_INI=$PHP_FPM/php.ini +PHP_POOL_DIR=$PHP_FPM/pool.d # Adminer ADMINERDIR=/usr/share/adminer ADMINER_CONF=/etc/apache2/conf-available/adminer.conf @@ -297,9 +298,9 @@ min_start_servers=20 min_max_spare_servers=35 # Calculate the sum of the current values -CURRENT_START="$(grep pm.start_servers $PHP_POOL_DIR/nextcloud.conf | awk '{ print $3}')" -CURRENT_MAX="$(grep pm.max_spare_servers $PHP_POOL_DIR/nextcloud.conf | awk '{ print $3}')" -CURRENT_MIN="$(grep pm.min_spare_servers $PHP_POOL_DIR/nextcloud.conf | awk '{ print $3}')" +CURRENT_START="$(grep pm.start_servers "$PHP_POOL_DIR"/nextcloud.conf | awk '{ print $3}')" +CURRENT_MAX="$(grep pm.max_spare_servers "$PHP_POOL_DIR"/nextcloud.conf | awk '{ print $3}')" +CURRENT_MIN="$(grep pm.min_spare_servers "$PHP_POOL_DIR"/nextcloud.conf | awk '{ print $3}')" CURRENT_SUM="$((CURRENT_START + CURRENT_MAX + CURRENT_MIN))" # Calculate max_children depending on RAM @@ -331,7 +332,7 @@ The installation was not successful, sorry for the inconvenience. If you think this is a bug, please report it to $ISSUES" exit 1 else - check_command sed -i "s|pm.max_children.*|pm.max_children = $PHP_FPM_MAX_CHILDREN|g" $PHP_POOL_DIR/nextcloud.conf + check_command sed -i "s|pm.max_children.*|pm.max_children = $PHP_FPM_MAX_CHILDREN|g" "$PHP_POOL_DIR"/nextcloud.conf print_text_in_color "$IGreen" "pm.max_children was set to $PHP_FPM_MAX_CHILDREN" # Check if the sum of all the current values are more than $PHP_FPM_MAX_CHILDREN and only continue it is if [ $PHP_FPM_MAX_CHILDREN -gt $CURRENT_SUM ] @@ -339,9 +340,9 @@ else # Set pm.max_spare_servers if [ $PHP_FPM_MAX_CHILDREN -ge $min_max_spare_servers ] then - if [ "$(grep pm.start_servers $PHP_POOL_DIR/nextcloud.conf | awk '{ print $3}')" -lt $min_start_servers ] + if [ "$(grep pm.start_servers "$PHP_POOL_DIR"/nextcloud.conf | awk '{ print $3}')" -lt $min_start_servers ] then - check_command sed -i "s|pm.max_spare_servers.*|pm.max_spare_servers = $((PHP_FPM_MAX_CHILDREN - 30))|g" $PHP_POOL_DIR/nextcloud.conf + check_command sed -i "s|pm.max_spare_servers.*|pm.max_spare_servers = $((PHP_FPM_MAX_CHILDREN - 30))|g" "$PHP_POOL_DIR"/nextcloud.conf print_text_in_color "$IGreen" "pm.max_spare_servers was set to $((PHP_FPM_MAX_CHILDREN - 30))" fi fi @@ -351,10 +352,10 @@ fi # If $PHP_FPM_MAX_CHILDREN is lower than the current sum of all values, revert to default settings if [ $PHP_FPM_MAX_CHILDREN -lt $CURRENT_SUM ] then - check_command sed -i "s|pm.max_children.*|pm.max_children = $PHP_FPM_MAX_CHILDREN|g" $PHP_POOL_DIR/nextcloud.conf - check_command sed -i "s|pm.start_servers.*|pm.start_servers = 3|g" $PHP_POOL_DIR/nextcloud.conf - check_command sed -i "s|pm.min_spare_servers.*|pm.min_spare_servers = 2|g" $PHP_POOL_DIR/nextcloud.conf - check_command sed -i "s|pm.max_spare_servers.*|pm.max_spare_servers = 3|g" $PHP_POOL_DIR/nextcloud.conf + check_command sed -i "s|pm.max_children.*|pm.max_children = $PHP_FPM_MAX_CHILDREN|g" "$PHP_POOL_DIR"/nextcloud.conf + check_command sed -i "s|pm.start_servers.*|pm.start_servers = 3|g" "$PHP_POOL_DIR"/nextcloud.conf + check_command sed -i "s|pm.min_spare_servers.*|pm.min_spare_servers = 2|g" "$PHP_POOL_DIR"/nextcloud.conf + check_command sed -i "s|pm.max_spare_servers.*|pm.max_spare_servers = 3|g" "$PHP_POOL_DIR"/nextcloud.conf print_text_in_color "$ICyan" "All PHP-INI values were set back to default values as the value for pm.max_children ($PHP_FPM_MAX_CHILDREN) was lower than the sum of all the current values ($CURRENT_SUM)" print_text_in_color "$ICyan" "Please run this again to set optimal values" fi diff --git a/nextcloud-startup-script.sh b/nextcloud-startup-script.sh index 79bf914328..93786123f3 100644 --- a/nextcloud-startup-script.sh +++ b/nextcloud-startup-script.sh @@ -537,10 +537,10 @@ restart_webserver if home_sme_server then # Add specific values to PHP-FPM based on 16 GB RAM - check_command sed -i "s|pm.max_children.*|pm.max_children = 307|g" $PHP_POOL_DIR/nextcloud.conf - check_command sed -i "s|pm.start_servers.*|pm.start_servers = 30|g" $PHP_POOL_DIR/nextcloud.conf - check_command sed -i "s|pm.min_spare_servers.*|pm.min_spare_servers = 20|g" $PHP_POOL_DIR/nextcloud.conf - check_command sed -i "s|pm.max_spare_servers.*|pm.max_spare_servers = 257|g" $PHP_POOL_DIR/nextcloud.conf + check_command sed -i "s|pm.max_children.*|pm.max_children = 307|g" "$PHP_POOL_DIR"/nextcloud.conf + check_command sed -i "s|pm.start_servers.*|pm.start_servers = 30|g" "$PHP_POOL_DIR"/nextcloud.conf + check_command sed -i "s|pm.min_spare_servers.*|pm.min_spare_servers = 20|g" "$PHP_POOL_DIR"/nextcloud.conf + check_command sed -i "s|pm.max_spare_servers.*|pm.max_spare_servers = 257|g" "$PHP_POOL_DIR"/nextcloud.conf restart_webserver else # Calculate the values of PHP-FPM based on the amount of RAM available (minimum 2 GB or 8 children) diff --git a/nextcloud_install_production.sh b/nextcloud_install_production.sh index 8ab04d42a9..98955bc6ad 100644 --- a/nextcloud_install_production.sh +++ b/nextcloud_install_production.sh @@ -295,7 +295,7 @@ a2enmod http2 restart_webserver # Set up a php-fpm pool with a unixsocket -cat << POOL_CONF > "$PHP_POOL_DIR/nextcloud.conf" +cat << POOL_CONF > "$PHP_POOL_DIR"/nextcloud.conf [Nextcloud] user = www-data group = www-data @@ -321,7 +321,7 @@ php_admin_value [cgi.fix_pathinfo] = 1 POOL_CONF # Disable the idling example pool. -mv $PHP_POOL_DIR/www.conf $PHP_POOL_DIR/www.conf.backup +mv "$PHP_POOL_DIR"/www.conf "$PHP_POOL_DIR"/www.conf.backup # Enable the new php-fpm config restart_webserver @@ -375,15 +375,15 @@ crontab -u www-data -l | { cat; echo "*/5 * * * * php -f $NCPATH/cron.php > # Change values in php.ini (increase max file size) # max_execution_time -sed -i "s|max_execution_time =.*|max_execution_time = 3500|g" $PHP_INI +sed -i "s|max_execution_time =.*|max_execution_time = 3500|g" "$PHP_INI" # max_input_time -sed -i "s|max_input_time =.*|max_input_time = 3600|g" $PHP_INI +sed -i "s|max_input_time =.*|max_input_time = 3600|g" "$PHP_INI" # memory_limit -sed -i "s|memory_limit =.*|memory_limit = 512M|g" $PHP_INI +sed -i "s|memory_limit =.*|memory_limit = 512M|g" "$PHP_INI" # post_max -sed -i "s|post_max_size =.*|post_max_size = 1100M|g" $PHP_INI +sed -i "s|post_max_size =.*|post_max_size = 1100M|g" "$PHP_INI" # upload_max -sed -i "s|upload_max_filesize =.*|upload_max_filesize = 1000M|g" $PHP_INI +sed -i "s|upload_max_filesize =.*|upload_max_filesize = 1000M|g" "$PHP_INI" # Set loggging occ_command config:system:set log_type --value=file @@ -424,7 +424,7 @@ echo "opcache.memory_consumption=256" echo "opcache.save_comments=1" echo "opcache.revalidate_freq=1" echo "opcache.validate_timestamps=1" -} >> $PHP_INI +} >> "$PHP_INI" # PHP-FPM optimization # https://geekflare.com/php-fpm-optimization/ @@ -442,7 +442,7 @@ echo "pgsql.max_persistent = -1" echo "pgsql.max_links = -1" echo "pgsql.ignore_notice = 0" echo "pgsql.log_notice = 0" -} >> /etc/php/$PHPVER/fpm/conf.d/20-pdo_pgsql.ini +} >> "$PHP_FPM_DIR"/conf.d/20-pdo_pgsql.ini # Install Redis (distrubuted cache) run_static_script redis-server-ubuntu @@ -463,7 +463,7 @@ echo "# igbinary for PHP" echo "extension=igbinary.so" echo "session.serialize_handler=igbinary" echo "igbinary.compact_strings=On" -} >> $PHP_INI +} >> "$PHP_INI" restart_webserver fi @@ -494,7 +494,7 @@ echo "apc.use_request_time=1" echo "apc.serializer=igbinary" echo "apc.coredump_unmap=0" echo "apc.preload_path" -} >> $PHP_INI +} >> "$PHP_INI" restart_webserver fi diff --git a/static/redis-server-ubuntu.sh b/static/redis-server-ubuntu.sh index 6e5bbea03e..3af674faa8 100644 --- a/static/redis-server-ubuntu.sh +++ b/static/redis-server-ubuntu.sh @@ -38,7 +38,7 @@ install_if_not redis-server # Setting direct to PHP-FPM as it's installed with PECL (globally doesn't work) print_text_in_color "$ICyan" "Adding extension=redis.so to $PHP_INI..." -echo 'extension=redis.so' >> $PHP_INI +echo 'extension=redis.so' >> "$PHP_INI" # Prepare for adding redis configuration sed -i "s|);||g" $NCPATH/config/config.php