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

Hi,

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 ??

Thanks.

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 https://global-social.net/script/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*
3 Likes

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.

Hi,

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.