Upgrade PHP 8.0 to 8.2

Hey guys,

i need help here: After upgrading our Nextcloud from 26 to 27, it tells me to upgrade my php version.

I actually never had to upgrade my PHP before and i am unsure on what to do. I have a Apache Webserver running the nextcloud.
from what i found online, i have to do

a2enmod php8.2
a2dismod php8.0
systemctl restart apache2

But when i do this and then visit my nextcloud site, i get greeted with the internal error screen.

php -v gives this output:
PHP 8.2.8 (cli) (built: Jul 8 2023 07:09:59) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.8, Copyright (c) Zend Technologies
with Zend OPcache v8.2.8, Copyright (c), by Zend Technologies

I have all these php modules installed:
apt list --installed | grep php

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libapache2-mod-php8.0/focal,now 1:8.0.29-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
libapache2-mod-php8.2/focal,now 8.2.8-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php-common/focal,now 2:93+ubuntu20.04.1+deb.sury.org+2 all [installed,automatic]
php-dompdf/focal,now 0.6.2+dfsg-3 all [installed]
php-font-lib/focal,now 0.3.1+dfsg-3 all [installed,automatic]
php-pear/focal,now 1:1.10.13+submodules+notgz+2022032202-2+ubuntu20.04.1+deb.sury.org+1 all [installed]
php7.4-apcu/focal,now 5.1.22+4.0.11-2+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.4-cli/focal,now 1:7.4.33-6+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.4-common/focal,now 1:7.4.33-6+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.4-json/focal,now 1:7.4.33-6+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.4-opcache/focal,now 1:7.4.33-6+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.4-phpdbg/focal,now 1:7.4.33-6+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php7.4-readline/focal,now 1:7.4.33-6+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php8.0-apcu/focal,now 5.1.22+4.0.11-2+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.0-bcmath/focal,now 1:8.0.29-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.0-cli/focal,now 1:8.0.29-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.0-common/focal,now 1:8.0.29-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php8.0-curl/focal,now 1:8.0.29-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.0-gd/focal,now 1:8.0.29-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.0-gmp/focal,now 1:8.0.29-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.0-igbinary/focal,now 3.2.14-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php8.0-imagick/focal,now 3.7.0-3+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.0-intl/focal,now 1:8.0.29-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.0-mbstring/focal,now 1:8.0.29-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.0-mysql/focal,now 1:8.0.29-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.0-opcache/focal,now 1:8.0.29-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php8.0-readline/focal,now 1:8.0.29-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php8.0-redis/focal,now 5.3.7+±1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.0-xml/focal,now 1:8.0.29-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.0-zip/focal,now 1:8.0.29-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed]
php8.0/focal,now 1:8.0.29-1+ubuntu20.04.1+deb.sury.org+1 all [installed]
php8.1-cli/focal,now 8.1.21-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php8.1-common/focal,now 8.1.21-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php8.1-igbinary/focal,now 3.2.14-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,auto-removable]
php8.1-opcache/focal,now 8.1.21-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php8.1-phpdbg/focal,now 8.1.21-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,auto-removable]
php8.1-readline/focal,now 8.1.21-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php8.1-redis/focal,now 5.3.7+±1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,auto-removable]
php8.2-cli/focal,now 8.2.8-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php8.2-common/focal,now 8.2.8-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php8.2-opcache/focal,now 8.2.8-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php8.2-readline/focal,now 8.2.8-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
php8.2/focal,now 8.2.8-1+ubuntu20.04.1+deb.sury.org+1 all [installed]

1 Like

php update has been described many times in this forum! The search function would have helped you.

You have a real mess installed.

You should first:

Remove unneeded php packages:

sudo apt-get remove --purge php7.4* php8.1*

Now install all php packages in 8.2 which you had in php 8.0:

for package in $(echo `dpkg -l | awk '/^ii.*php8.0/ {print $2}' | sed 's/php8.0/php8.2/g'`); do sudo apt-get -y install $package; done

That is the installation part. Now you have to adapt your php.ini settings from 8.0 to 8.2

You can use the script php-updater for that. It reads step by step every setting you made in 8.0 and asks if you want to port that setting to your new (8.2) ini file. It can also do the update part but that is not necessary as I explained that steps in the previous paragraph:

sudo wget -qO /usr/local/bin/php-updater https://global-social.net/script/php-updater
sudo chmod +x /usr/local/bin/php-updater
php-updater 8.0 8.2
More about the php-updater script: Php-updater - a script to upgrade php in a safe way

Hope that helps,
much luck!

3 Likes

Thank you so much, this worked great!

yes i saw a few Posts here and on other Sites but since i have to execute this on a live-production server as i currently DO NOT have a Test System to try stuff out i made the Post to be 100% Sure in the things i do. I will clone this Server this week tough and make sure that i have a testing system setup with it.

Thanks again!

1 Like