PHP 7.4 to 8.0 to support upgrade NC25 to NC26 on NextcloudPi, server down


I have NextcloudPi running on Rock64 (Pi like) under Armbian BullsEye.
I’m running NC V25.0.3.
NCP 1.52.0 enable update to V26.

At the end of update, there is an abort because of PHP 7.4.33. Need to update PHP8.0.
But when I do the PHP8.0 update (with Sury package source), my NC server goes down.
In the System Info of NCP web, NextCLoud check : error ; HPB service : down. All other are green.
And NCP, when asking to update to last NextCloud, tells me the server is down and doesn’t do the update…

For the server to be up, I have to go back to PHP7.4, so no NC upgrade…

How do I get out of this loop ??


Did you try to upgrade php first from 7.4 to 8.0 or 8.1?
Can you use NC and your rock normal?

I’ve tried many things.

I did once upgrade PHP to 8.0.
Server is up and running but for NCP it’s down (as HPB service) and it refuse to upgrade NC from 25 to 26.

Before trying to upgrade I made an image of my SDcard so I can easily go back to a working setup :wink:

Do you have any logfiles you can check why its not working/no access possible?
Check the NC logs and your webserver logs. Maybe you see anything interesting there.

Doing some tests I figured something.

When installing PHP8.0 (‘php -v’ gives me ‘PHP 8.0 is running’), ‘php8.0-fpm’ is not installed so PHP is using php7.4-fpm.
NextCloud Admin Overview tells me I’m using php 7.4.33 and I should update.

Nextcloud works with this setting, I can acces my datas, but for NextCloudPi, I have ‘Nextcloud check’ and ‘HPB service’ error (so no NC26 update possible).

If I try to install ‘php8.0-fpm’ and enable it ‘a2enconf php8.0-fpm’ then I got ‘Internal sever Error’ when trying to load my NC webpage.

I think my problem is with the fpm thing.

Regarding the logs, where should I look ?
Too much ‘Permission denied’ when trying to access /var/www/nextcloud ot /var/log/apache2…

I have written a script for a safe php upgrade on debian like systems:

  1. go back to your 7.4

  2. remove all NOT-7.4 packages and all so caled “dependency-packages” and “meta-packages”:
    The automatic update from one to the next version is done by so called “dependency-packages” like ‘php ’ and other packages with names like php-{module} (without the version String) Those packages can almost all safely be removed, what will give you back the control over your php-version. When you try to deinstall a package, you will see if it is a dependency for one or more php7.4-* modules (like php-common which is allways needed). All other packages that don’t meet any dependencies can and should be removed.
    A package as ‘php7.4 ’ is a so caled “meta-package” and can be removed too.

  3. Download the script

sudo wget -qO /usr/local/bin/php-updater
sudo chmod +x /usr/local/bin/php-updater
  1. execute the script simply by calling it:
    sudo php-updater
    it looks what php-version actually is installed and asks which new version you want to install. (First I would recommend 8.0). After the installation it migrates all settings from your old php-installation (php.ini for php-cli and php-apache2 or - in case you are using php-fpm - the php.ini for php-fpm and pool.d/www.conf for php-fpm) into the new version.
    If you already have installed one or more new versions (e.g. 8.0 and 8.1), you can use the script for only the later step (the migration from all setting) by calling it
    sudo php-updater 7.4 8.0
    In this case, it takes the settings from your 7.4 Version and helps you to integrate them into the 8.0 version.

  2. Run this command to control, if all php-versions are switched to the version you want. I would recommend to not leave it in automatic mode but choosing the respective manual mode so that no unintentional version changes can take place, but only after your conscious change (using this command):

(updated: added sudo, see #8):

for linkgroup in $(ls /var/lib/dpkg/alternatives/ | grep -E "ph(ar|p)"); do sudo update-alternatives --config $linkgroup; done
  1. finaly change the used php-version in your apache server (updated: added libapache2-mod-php):
  • 1). for libapache2-mod-php:
sudo a2dismod php7.4
sudo a2enmod php8.0
sudo apachectl restart
  • 2). for php-fpm:
sudo a2disconf php7.4-fpm
sudo a2enconf php8.0-fpm
sudo apachectl restart
  1. After everything runs nice, you can remove all old php packages:
    sudo apt-get remove --purge php7.4*

Thanks for the help :slight_smile:
I tried to compare php.ini from 7.4 and 8.0 to see if there was some settings differences but too long file ^^’

At step 5, at the ends of the questions, I got some permission denied for writing settings, for exemple at the full end (I selected ‘2’, 8.0 manual mode, for all the questions) :

"There are 2 choices for the alternative php (providing /usr/bin/php).

  • Selection Path Priority Status*
    ** 0 /usr/bin/php8.0 80 auto mode*
  • 1 /usr/bin/php7.4 74 manual mode*
  • 2 /usr/bin/php8.0 80 manual mode*

Press to keep the current choice[], or type selection number: 2*
update-alternatives: error: unable to create file ‘/var/lib/dpkg/alternatives/php.dpkg-tmp’: Permission denied
update-alternatives: warning: alternative /run/php/php8.0-fpm.sock (part of link group php-fpm.sock) doesn’t exist; removing from list of alternatives
update-alternatives: warning: /etc/alternatives/php-fpm.sock is dangling; it will be updated with best choice
There is only one alternative in link group php-fpm.sock (providing /run/php/php-fpm.sock): /run/php/php8.0-fpm.sock
Nothing to configure.
update-alternatives: error: unable to create file ‘/var/lib/dpkg/alternatives/php-fpm.sock.dpkg-tmp’: Permission denied"

/var/lib/dpkg/alternative/ path is root:root owned…

I created a dummy ‘php.dpkg-tmp’ file with pi:pi owner so the command could modity the file but then got some permission denied for moving ‘php.dpkg-tmp’ to ‘php’.
What should I do to enable/fix this ?

I forgot to precede sudo. Try this way:

for linkgroup in $(ls /var/lib/dpkg/alternatives/ | grep -E "ph(ar|p)"); do sudo update-alternatives --config $linkgroup; done

but that is done by the php-updater script (Step 3. and 4.). Did you not run that one?

That should not happen if you did the update steps 1. - 4. (with the php-updater script).
Did you use php-fpm before or libapache2-mod-php7.4?

If not and if you want to change to php-fpm, you need to change Step 6:

sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php8.0-fpm
sudo apachectl restart

I know and I used it.
I tried to compare before reading your post as I thought it was a config problem.

I think the things I tried today before you posted your help messed up my setting.
Tomorrow morning I’ll restore my backup image to use your script on a working install.

I’ll keep you posted.
Thanks for your time :wink:

I want to tone down your hopes a bit as I’m not an expert on NCPi.
My advice more or less assumed php-fpm was used, you mentioned that somewhere, but that doesn’t seem to be the case.
However, the update script only updates those packages that are already installed. So if libapache2-mod-php7.4 was installed and you selected 8.0 as the new version, then it will also install libapache2-mod-php8.0 and not php8.0-fpm unless php7.4-fpm was already present before (which doesn’t seem to be the case).

Nevertheless, the script cannot do any harm and makes it much easier to take over the php.ini settings (that’s what I originally wrote it for).

In my previous posts, I explained how to switch php version when using php-fpm or how to activate it.

Please note: the steps to switch php-version from 7.4 to 8.0 with libapache2-mod-php are:

sudo a2dismod php7.4
sudo a2enmod php8.0

All the rest (done by the script) stays the same.


I thought you script would install PHP8.0.
So I did it and ran your script.

Everything went flowless.
But at the end when changing the used fpm from 7.4 to 8.0 (a2enconf…), I got “Internal server Error” on my server webpage.

I think I’ll go for my plan B : backup my setup, use a new NextCloudPi image with NextCloud 26 installed (with PHP8.0) and then restore.
My original image is from 2019. At some point, fresh install is better.

Nevertheless, thanks for your time.

1 Like

I was almost hit by first Murphy’s rule : Never try to fix something working !

I made a backup and export my NCP setting.
I wrote a new NCP image (1.52 + NC26 and PHP8).
I restored my backup and import my settings. (logically went back to NC25 but with PHP8.0)
=> the path to my datas was not restored, my Let’s encrypt was not working (couldn’t write registered adress file).

As I only have one MicroSD card I have to joggle between images.

At the end, I restored my NC25/PHP7.4 image and got my setup working again.

Think I’ll wait for Armbian update (this summe as other Debian distro) to have PHP8.0 properly installed and then update to NC26.