From 88efc08a08c2414570dca43b6f0c41bec1cd5d50 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Fri, 13 Oct 2017 15:04:43 +0200 Subject: [PATCH 1/3] WORK IN PROCESS: Move PHP settings from webserver to PHP config files ...as e.g. enabling caching for CLI has no effect inside webserver config, which is not asked by CLI requests, e.g. by cron. We just leave the critical opcache size inside webserver config, in case hard coding 128M, so this will not allow other web services to full the cache and cause swapping. --- dietpi/dietpi-software | 41 +++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index 7dfd68eb28..7b527b78d1 100644 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -8591,8 +8591,19 @@ _EOF_ phpenmod ctype dom fileinfo iconv mbstring posix simplexml xmlwriter xmlreader zip exif fi - - #Create Nextcloud specific webserver + PHP config. + + # APCu configuration: To prevent cli (cron.php) producing Nextcloud log [info] entry. + grep -q 'apc.enable_cli=' $FP_PHP_BASE_DIR/mods-available/apcu.ini && sed -i '/apc.enable_cli=/c\apc.enable_cli=1' $FP_PHP_BASE_DIR/mods-available/apcu.ini || echo 'apc.enable_cli=1' >> $FP_PHP_BASE_DIR/mods-available/apcu.ini + + # OPCache configuration: https://docs.nextcloud.com/server/12/admin_manual/configuration_server/server_tuning.html?highlight=opcache#enable-php-opcache + grep -q 'opcache.enable=' $FP_PHP_BASE_DIR/mods-available/opcache.ini && sed -i '/opcache.enable=/c\opcache.enable=1' $FP_PHP_BASE_DIR/mods-available/opcache.ini || echo 'opcache.enable=1' >> $FP_PHP_BASE_DIR/mods-available/opcache.ini + grep -q 'opcache.enable_cli=' $FP_PHP_BASE_DIR/mods-available/opcache.ini && sed -i '/opcache.enable_cli=/c\opcache.enable_cli=1' $FP_PHP_BASE_DIR/mods-available/opcache.ini || echo 'opcache.enable_cli=1' >> $FP_PHP_BASE_DIR/mods-available/opcache.ini + grep -q 'opcache.interned_strings_buffer=' $FP_PHP_BASE_DIR/mods-available/opcache.ini && sed -i '/opcache.interned_strings_buffer=/c\opcache.interned_strings_buffer=8' $FP_PHP_BASE_DIR/mods-available/opcache.ini || echo 'opcache.interned_strings_buffer=8' >> $FP_PHP_BASE_DIR/mods-available/opcache.ini + grep -q 'opcache.max_accelerated_files=' $FP_PHP_BASE_DIR/mods-available/opcache.ini && sed -i '/opcache.max_accelerated_files=/c\opcache.max_accelerated_files=10000' $FP_PHP_BASE_DIR/mods-available/opcache.ini || echo 'opcache.max_accelerated_files=10000' >> $FP_PHP_BASE_DIR/mods-available/opcache.ini + grep -q 'opcache.save_comments=' $FP_PHP_BASE_DIR/mods-available/opcache.ini && sed -i '/opcache.save_comments=/c\opcache.save_comments=1' $FP_PHP_BASE_DIR/mods-available/opcache.ini || echo 'opcache.save_comments=1' >> $FP_PHP_BASE_DIR/mods-available/opcache.ini + grep -q 'opcache.revalidate_freq=' $FP_PHP_BASE_DIR/mods-available/opcache.ini && sed -i '/opcache.revalidate_freq=/c\opcache.revalidate_freq=1' $FP_PHP_BASE_DIR/mods-available/opcache.ini || echo 'opcache.revalidate_freq=1' >> $FP_PHP_BASE_DIR/mods-available/opcache.ini + + #Create Nextcloud specific webserver config. #Apache: https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html#apache-web-server-configuration if (( ${aSOFTWARE_INSTALL_STATE[83]} >= 1 )); then @@ -8611,31 +8622,9 @@ Alias /nextcloud "/var/www/nextcloud/" SetEnv HOME /var/www/nextcloud SetEnv HTTP_HOME /var/www/nextcloud - # OPCache configuration: https://docs.nextcloud.com/server/12/admin_manual/configuration_server/server_tuning.html?highlight=opcache#enable-php-opcache - #php_admin_value opcache.enable 1 defaults anyway and isn't possible here: http://php.net/manual/en/opcache.configuration.php#ini.opcache.enable - php_admin_value opcache.enable_cli 1 - php_admin_value opcache.interned_strings_buffer 8 - php_admin_value opcache.max_accelerated_files 10000 - php_admin_value opcache.memory_consumption $(( $RAM_TOTAL / 10 )) - php_admin_value opcache.save_comments 1 - php_admin_value opcache.revalidate_freq 1 - - # MySQL/MariaDB configuration: https://docs.nextcloud.com/server/12/admin_manual/configuration_database/linux_database_configuration.html#configuring-a-mysql-or-mariadb-database - php_admin_value mysql.allow_local_infile 1 - php_admin_value mysql.allow_persistent 1 - php_admin_value mysql.cache_size 2000 - php_admin_value mysql.max_persistent -1 - php_admin_value mysql.max_links -1 - php_admin_value mysql.default_port 0 - php_admin_value mysql.default_socket /var/run/mysqld/mysqld.sock - #php_admin_value mysql.default_host - #php_admin_value mysql.default_user - #php_admin_value mysql.default_password - php_admin_value mysql.connect_timeout 60 - php_admin_value mysql.trace_mode 0 - # APCu configuration: To prevent cron.php produce Nextcloud log [info] entry. - php_admin_value apc.enable_cli 1 + #Hard coding 128M OPCache size, only for /nextcloud, to suppress warning on nextcloud admin panel. + php_admin_value opcache.memory_consumption 128 _EOF_ From 62f37a95f61c574aff57621284fecd9cfde01ede Mon Sep 17 00:00:00 2001 From: MichaIng Date: Fri, 13 Oct 2017 16:07:24 +0200 Subject: [PATCH 2/3] Adjust also for Nginx --- dietpi/dietpi-software | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index 7b527b78d1..7a4fab420c 100644 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -8622,8 +8622,7 @@ Alias /nextcloud "/var/www/nextcloud/" SetEnv HOME /var/www/nextcloud SetEnv HTTP_HOME /var/www/nextcloud - - #Hard coding 128M OPCache size, only for /nextcloud, to suppress warning on nextcloud admin panel. + # Hard coding 128M OPCache size, only for /nextcloud, to suppress warning on nextcloud admin panel. php_admin_value opcache.memory_consumption 128 @@ -8677,7 +8676,7 @@ location ^~ /nextcloud { fastcgi_param REMOTE_USER \$remote_user; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_intercept_errors on; - # Disable because Jessie Nginx does not support that parameter + # Disable because Jessie Nginx does not support that parameter #fastcgi_request_buffering off; } @@ -8707,17 +8706,8 @@ location ^~ /nextcloud { access_log off; } - # Setting PHP values by using this method: http://php.net/manual/en/install.fpm.configuration.php Example #2 - # OPCache configuration: https://docs.nextcloud.com/server/12/admin_manual/configuration_server/server_tuning.html?highlight=opcache#enable-php-opcache - # APCu configuration: To prevent cron.php produce Nextcloud log [info] entry. - #"opcache.enable=1" defaults anyway and isn't possible here: http://php.net/manual/en/opcache.configuration.php#ini.opcache.enable - fastcgi_param PHP_ADMIN_VALUE "opcache.enable_cli=1 - opcache.interned_strings_buffer=8 - opcache.max_accelerated_files=10000 - opcache.memory_consumption=$(( $RAM_TOTAL / 10 )) - opcache.save_comments=1 - opcache.revalidate_freq=1 - apc.enable_cli=1"; + # Hard coding 128M OPCache size, only for /nextcloud, to suppress warning on nextcloud admin panel. + fastcgi_param PHP_ADMIN_VALUE "opcache.memory_consumption=128" } _EOF_ From 919602fe24f6de332415410ce599cda719f5b3d4 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Fri, 13 Oct 2017 16:15:38 +0200 Subject: [PATCH 3/3] small Nginx conf fix ";" at end of directive --- dietpi/dietpi-software | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index 7a4fab420c..0d39b56f79 100644 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -8582,10 +8582,10 @@ _EOF_ INSTALLING_INDEX=114 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then - #Install/Enable necessary PHP modules: https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation + # Install/Enable necessary PHP modules: https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation AGI "$PHP_APT_PACKAGE_NAME"-intl ${PHP_APT_PACKAGE_NAME}enmod curl gd intl json pdo_mysql opcache apcu - #Solve: https://github.com/Fourdee/DietPi/issues/1067#issuecomment-335200352 + # Solve: https://github.com/Fourdee/DietPi/issues/1067#issuecomment-335200352 if (( $DISTRO >= 4 )); then phpenmod ctype dom fileinfo iconv mbstring posix simplexml xmlwriter xmlreader zip exif @@ -8603,8 +8603,8 @@ _EOF_ grep -q 'opcache.save_comments=' $FP_PHP_BASE_DIR/mods-available/opcache.ini && sed -i '/opcache.save_comments=/c\opcache.save_comments=1' $FP_PHP_BASE_DIR/mods-available/opcache.ini || echo 'opcache.save_comments=1' >> $FP_PHP_BASE_DIR/mods-available/opcache.ini grep -q 'opcache.revalidate_freq=' $FP_PHP_BASE_DIR/mods-available/opcache.ini && sed -i '/opcache.revalidate_freq=/c\opcache.revalidate_freq=1' $FP_PHP_BASE_DIR/mods-available/opcache.ini || echo 'opcache.revalidate_freq=1' >> $FP_PHP_BASE_DIR/mods-available/opcache.ini - #Create Nextcloud specific webserver config. - #Apache: https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html#apache-web-server-configuration + # Create Nextcloud specific webserver config. + # Apache: https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html#apache-web-server-configuration if (( ${aSOFTWARE_INSTALL_STATE[83]} >= 1 )); then a2enmod rewrite headers env dir mime @@ -8632,7 +8632,7 @@ _EOF_ fi - #Nginx: https://docs.nextcloud.com/server/12/admin_manual/installation/nginx.html#nextcloud-in-a-subdir-of-nginx + # Nginx: https://docs.nextcloud.com/server/12/admin_manual/installation/nginx.html#nextcloud-in-a-subdir-of-nginx if (( ${aSOFTWARE_INSTALL_STATE[85]} >= 1 )); then cat << _EOF_ > /etc/nginx/sites-dietpi/nextcloud.config @@ -8671,7 +8671,7 @@ location ^~ /nextcloud { fastcgi_param SCRIPT_FILENAME \$request_filename; fastcgi_param PATH_INFO \$fastcgi_path_info; fastcgi_param HTTPS on; - #Avoid sending the security headers twice + # Avoid sending the security headers twice fastcgi_param modHeadersAvailable true; fastcgi_param REMOTE_USER \$remote_user; fastcgi_pass unix:/var/run/php5-fpm.sock; @@ -8707,7 +8707,7 @@ location ^~ /nextcloud { } # Hard coding 128M OPCache size, only for /nextcloud, to suppress warning on nextcloud admin panel. - fastcgi_param PHP_ADMIN_VALUE "opcache.memory_consumption=128" + fastcgi_param PHP_ADMIN_VALUE "opcache.memory_consumption=128"; } _EOF_