Upgrade php7 to php8 for Nextcloud on openSUSE-15.5
Geplaatst op vr 04 augustus 2023 in Linux
People that run Nextcloud-25 on openSUSE-15.5, and wanting to upgrade to newer a Nextcloud version have to upgrade their php version from php7 to php8, as Nextcloud beyond version 25 no longer supports php7, see Upgrade to Nextcloud 26.
This article provides a procedure to upgrade php7 to php8 for Nextcloud on openSUSE-15.5.
It's just a help, review the commands and instructions in this procedure, carefully.
As always: backup, backup, backup!
Procedure
On openSUSE-15.5 determine the installed php7 packages:
rpm -qa --qf "%{NAME}\n" | grep php7 | sort
Result:
In total 31 php7 are installed on the system used for this procedure:
apache2-mod_php7
php7
php7-APCu
php7-bcmath
...
php7-xmlwriter
php7-zip
php7-zlib
Optional: want a newer version?
The following is fully optional, if you want to stick with the rpms provided by openSUSE-15.5 skip this section!
In case you want a php8 newer then that is provided by openSUSE-15.5, add the following two repositories to your system.
openSUSE-15.5 provides php-8.0, while the one below provides php-8.1/
Use the following commands, to add these repositories:
zypper addrepo --refresh https://download.opensuse.org/repositories/devel:/languages:/php:/php81/openSUSE_Leap_15.5/devel:languages:php:php81.repo
zypper addrepo --refresh https://download.opensuse.org/repositories/server:/php:/extensions/15.5/server:php:extensions.repo
Check with: zypper repos devel_languages_php_php81 server_php_extensions
.
The output should confirm the correct configuration of the 2 newly added repositories.
Verification and Backup
The functionality provided by php7-json is provided by the php8, and this package can be neglected in the rest of the procedure.
Store the php7 packages to be upgraded in an environment variable and review what was changed/updated:
RPMS=$( rpm -qa --qf "%{NAME}\n" | grep php7 )
echo "$RPMS"
echo "$RPMS" > /var/tmp/php7-rpms
rpm -Va $RPMS
Result:
S.5....T. c /etc/php7/apache2/php.ini
..5....T. c /etc/php7/cli/php.ini
Not much changed. All the other configuration files are unchanged (about 30 in my case).
The list with packages are available in the file /var/tmp/php7-rpms
.
Backup
Make a backup of the changed configuration files:
tar cf /var/tmp/php7-config.tar $( rpm -Va $RPMS | awk '{ print $3 }' )
tar tf /var/tmp/php7-config.tar
Verification
Update the package cache (when asked trust the repository keys):
zypper refresh
Create a new package list, this time without the php7-json package:
RPMS=$( rpm -qa --qf "%{NAME}\n" | grep php7 | grep -vEi "json" | sed 's/php7/php8/' | sort )
echo "$RPMS"
Check that all the packages can be upgraded:
zypper install --dry-run $RPMS
Result:
It reports 28 problems, with 30 solutions to deinstall the php7 package that will be replaced by its php8 counter part.
After pressing ‘1’ many times, zypper proceeds:
Resolving dependencies...
Resolving package dependencies...
The following 8 recommended packages were automatically selected:
php8-ctype php8-dom php8-iconv php8-openssl php8-sqlite php8-tokenizer php8-xmlreader php8-xmlwriter
The following 30 NEW packages are going to be installed:
apache2-mod_php8 php8 php8-bcmath php8-cli php8-ctype php8-curl php8-dom php8-fileinfo php8-ftp php8-gd php8-gettext php8-gmp php8-iconv
php8-intl php8-mbstring php8-mysql php8-opcache php8-openssl php8-pcntl php8-pdo php8-pear php8-phar php8-posix php8-sqlite
php8-tokenizer php8-xmlreader php8-xmlwriter php8-zip php8-zlib
The following 31 packages are going to be REMOVED:
apache2-mod_php7 php7 php7-APCu php7-bcmath php7-cli php7-ctype php7-curl php7-dom php7-fileinfo php7-ftp php7-gd php7-gettext php7-gmp
php7-iconv php7-imagick php7-intl php7-json php7-mbstring php7-mysql php7-opcache php7-openssl php7-pcntl php7-pdo php7-pear php7-posix
php7-sqlite php7-tokenizer php7-xmlreader php7-xmlwriter php7-zip php7-zlib
29 new packages to install, 31 to remove.
If this looks good to you, continue to upgrade.
Upgrade from php-7 to php-8
zypper install --download-in-advance $RPMS
Update the memory configuration. Check what it was before, in the config files that were saved before:
sed -i 's/^\(memory_limit\) = 128M/\1 = 512M/' /etc/php8/cli/php.ini
sed -i 's/^\(memory_limit\) = 128M/\1 = 512M/' /etc/php8/apache2/php.ini
Restart the webserver:
rcapache2 restart
rcapache2 status
After this, Nextcloud should be humming again nicely, but now driven by php8.
Check the Nextcloud (security) configuraton on https://<fqdn>/settings/admin/overview.
The warning on the settings/admin/overview page about php-7.xx should no longer be displayed, nor should any other warning be displayed.
Although, it could be that the following warning is displayed:
The OPcache interned strings buffer is nearly full. To assure that repeating strings can be effectively cached,
it is recommended to apply **opcache.interned_strings_buffer** to your PHP configuration with a value higher
than 8
This can be achieved by executed the following commands:
grep interned_strings_buffer /etc/php8/apache2/php.ini /etc/php8/cli/php.ini
sed -i 's/;opcache.interned_strings_buffer=8/opcache.interned_strings_buffer=10/' /etc/php8/cli/php.ini
sed -i 's/;opcache.interned_strings_buffer=8/opcache.interned_strings_buffer=10/' /etc/php8/apache2/php.ini
grep interned_strings_buffer /etc/php8/apache2/php.ini /etc/php8/cli/php.ini
The 8 should now have turned into a 10.
Restart the webserver:
rcapache2 restart
rcapache2 status