How to switch to 8.2 by default

Hello,
on raspberry I have 3 different versions of php installed
7.3, 7.4, 8.2
and the default version is 7.3

Do you know how to switch to 8.2 by default?

thank you

pi@rasp:~ $ ls /etc/php/
7.3  7.4  8.2
pi@rasp:~ $ ls /etc/php/7.3
cli  fpm  mods-available
pi@paulo:~ $ ls /etc/php/7.4
mods-available
pi@rasp:~ $ ls /etc/php/8.2
mods-available
pi@rasp:~ $ php --version
PHP 7.3.31-1~deb10u4 (cli) (built: Jun 19 2023 19:10:11) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.31, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.31-1~deb10u4, Copyright (c) 1999-2018, by Zend Technologies

Can have a look at How to Install and Run Latest PHP on Raspberry Pi
Question, though valid, is not really Nextcloud nor NCP related.
How did you install Nextloud?
NCP installs with php8.1 at the moment (NextCloudPi v1.52.4)

You ain’t have any php-sapi versions installed under 7.4 and 8.2.

First I want to make clear that I know Debian well, but I’m not a pi expert at all and I don’t know how you installed Nextcloud either.


here are a few helpfull command lines:

Install exactly the packages and sapi versions for version 8.2 that you have now installed for version 7.3:

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

migrate all settings from 7.3 to 8.2.
You can do this cumbersomely by hand or use the handy php-updater helper script:

sudo wget -O /usr/local/bin/php-updater https://global-social.net/apps/raw/s/php-updater
sudo chmod +x /usr/local/bin/php-updater
sudo php-updater 7.3 8.2

(edited: added sudo)

Switch all php-Packages with the update-alternative mechanism to use 8.2:

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

And you have to switch your webserver - eather apache or nginx - to use the new php-fpm.

But again, I have no information about the type of your installation. Appliances like docker may need to be treated differently.

Hope this helps,

much luck!

Thank you very much for your help OliverV and ernolf.
some explanations of my configuration
raspberry 4
Raspbian GNU/Linux 10. 5.10.103-v7l+ (armv7l)
I installed NCP with a command that looked like this: curl -sSL https://raw.githubusercontent.com/nextcloud/nextcloudpi/master/install.sh | sudo bash
I only use my raspberry with nextcloudpi

I’m going to start the procedure again as it contained errors.

I’m going to start again by installing php 8.2
does the procedure here How to Install and Run Latest PHP on Raspberry Pi install all the packages?

Hello,
I’ve done the whole procedure but unfortunately I have a problem with chmod and php-updater (see code below)
when I call my domain I get:

Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.


pi@home:~ $ sudo wget -O /usr/local/bin/php-updater https://global-social.net/apps/raw/s/php-updater
--2023-08-20 20:57:10--  https://global-social.net/apps/raw/s/php-updater
Résolution de global-social.net (global-social.net)… 84.189.143.159
Connexion à global-social.net (global-social.net)|84.189.143.159|:443… connecté.
requête HTTP transmise, en attente de la réponse… 200 OK
Taille : non indiqué [text/x-shellscript]
Sauvegarde en : « /usr/local/bin/php-updater »

/usr/local/bin/php-updater      [ <=>                                     ]  10.34K  --.-KB/s    ds 0.001s

2023-08-20 20:57:11 (10.8 MB/s) - « /usr/local/bin/php-updater » sauvegardé [10586]

pi@home:~ $ chmod +x /usr/local/bin/php-updater
chmod: modification des droits de '/usr/local/bin/php-updater': Opération non permise
pi@home:~ $ sudo php-updater 7.3 8.2
sudo: php-updater : commande introuvable
pi@home:~ $

Excuse me, you obviously need sudo for it:

sudo chmod +x /usr/local/bin/php-updater

much luck!

Thank you very much for your help
the sudo command was used to lace the script, but unfortunately the result is not positive, I have the error:

Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

here is the result of the script
I confirmed yes to all the questions

pi@home:~ $ sudo chmod +x /usr/local/bin/php-updater
pi@home:~ $ sudo php-updater 7.3 8.2

Do you want to migrate the values from the config file(s) for "php-cli"
from version 7.3 into the corresponding php.ini for version 8.2? (Y/n) y

Setting "%H:%M:%S"" not found in /etc/php/8.2/cli/php.ini
Do you want to append it to the end of the file? (Y/n) y
Setting "%H:%M:%S" = %H:%M:%S"" appended to the end of /etc/php/8.2/cli/php.ini

The value for "html_errors" is not set
Do you want to set "html_errors" with the old value "On"? (Y/n) y
Setting "html_errors = On" added after line 561 in /etc/php/8.2/cli/php.ini

Setting "ibase.allow_persistent" not found in /etc/php/8.2/cli/php.ini
Do you want to append it to the end of the file? (Y/n) y
Setting "ibase.allow_persistent = 1" appended to the end of /etc/php/8.2/cli/php.ini

Setting "ibase.dateformat" not found in /etc/php/8.2/cli/php.ini
Do you want to append it to the end of the file? (Y/n) y
Setting "ibase.dateformat = "%Y-%m-%d"" appended to the end of /etc/php/8.2/cli/php.ini

Setting "ibase.max_links" not found in /etc/php/8.2/cli/php.ini
Do you want to append it to the end of the file? (Y/n) y
Setting "ibase.max_links = -1" appended to the end of /etc/php/8.2/cli/php.ini

Setting "ibase.max_persistent" not found in /etc/php/8.2/cli/php.ini
Do you want to append it to the end of the file? (Y/n) y
Setting "ibase.max_persistent = -1" appended to the end of /etc/php/8.2/cli/php.ini

Setting "ibase.timeformat" not found in /etc/php/8.2/cli/php.ini
Do you want to append it to the end of the file? (Y/n) y
Setting "ibase.timeformat = "%H:%M:%S"" appended to the end of /etc/php/8.2/cli/php.ini

Setting "ibase.timestampformat" not found in /etc/php/8.2/cli/php.ini
Do you want to append it to the end of the file? (Y/n) y
Setting "ibase.timestampformat = "%Y-%m-%d" appended to the end of /etc/php/8.2/cli/php.ini

Setting "log_errors_max_len" not found in /etc/php/8.2/cli/php.ini
Do you want to append it to the end of the file? (Y/n) y
Setting "log_errors_max_len = 1024" appended to the end of /etc/php/8.2/cli/php.ini

Setting "uploadtmp_dir" not found in /etc/php/8.2/cli/php.ini
Do you want to append it to the end of the file? (Y/n) y
Setting "uploadtmp_dir = /media/myCloudDrive/ncdata/tmp" appended to the end of /etc/php/8.2/cli/php.ini

Do you want to migrate the values from the config file(s) for "php-fpm"
from version 7.3 into the corresponding php.ini for version 8.2? (Y/n) y

The value for "disable_functions" differs: new value ""
Do you want to set "disable_functions" to the old value "pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,"? (Y/n) y
Changed disable_functions from "" to "pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,"

Setting "%H:%M:%S"" not found in /etc/php/8.2/fpm/php.ini
Do you want to append it to the end of the file? (Y/n) y
Setting "%H:%M:%S" = %H:%M:%S"" appended to the end of /etc/php/8.2/fpm/php.ini

The value for "html_errors" is not set
Do you want to set "html_errors" with the old value "On"? (Y/n) y
Setting "html_errors = On" added after line 562 in /etc/php/8.2/fpm/php.ini

Setting "ibase.allow_persistent" not found in /etc/php/8.2/fpm/php.ini
Do you want to append it to the end of the file? (Y/n) y
Setting "ibase.allow_persistent = 1" appended to the end of /etc/php/8.2/fpm/php.ini

Setting "ibase.dateformat" not found in /etc/php/8.2/fpm/php.ini
Do you want to append it to the end of the file? (Y/n) y
Setting "ibase.dateformat = "%Y-%m-%d"" appended to the end of /etc/php/8.2/fpm/php.ini

Setting "ibase.max_links" not found in /etc/php/8.2/fpm/php.ini
Do you want to append it to the end of the file? (Y/n) y
Setting "ibase.max_links = -1" appended to the end of /etc/php/8.2/fpm/php.ini

Setting "ibase.max_persistent" not found in /etc/php/8.2/fpm/php.ini
Do you want to append it to the end of the file? (Y/n) y
Setting "ibase.max_persistent = -1" appended to the end of /etc/php/8.2/fpm/php.ini

Setting "ibase.timeformat" not found in /etc/php/8.2/fpm/php.ini
Do you want to append it to the end of the file? (Y/n) y
Setting "ibase.timeformat = "%H:%M:%S"" appended to the end of /etc/php/8.2/fpm/php.ini

Setting "ibase.timestampformat" not found in /etc/php/8.2/fpm/php.ini
Do you want to append it to the end of the file? (Y/n) y
Setting "ibase.timestampformat = "%Y-%m-%d" appended to the end of /etc/php/8.2/fpm/php.ini

Setting "log_errors_max_len" not found in /etc/php/8.2/fpm/php.ini
Do you want to append it to the end of the file? (Y/n) y
Setting "log_errors_max_len = 1024" appended to the end of /etc/php/8.2/fpm/php.ini

The value for "sys_temp_dir" is not set
Do you want to set "sys_temp_dir" with the old value "/media/myCloudDrive/ncdata/tmp"? (Y/n) y
Setting "sys_temp_dir = /media/myCloudDrive/ncdata/tmp" added after line 776 in /etc/php/8.2/fpm/php.ini

The value for "upload_tmp_dir" is not set
Do you want to set "upload_tmp_dir" with the old value "/media/myCloudDrive/ncdata/tmp"? (Y/n) y
Setting "upload_tmp_dir = /media/myCloudDrive/ncdata/tmp" added after line 854 in /etc/php/8.2/fpm/php.ini

Do you want to migrate the values from the config file "pool.d/www.conf" for "fpm"
from version 7.3 into the corresponding "pool.d/www.conf" for version 8.2? (Y/n) y

The value for "pm" differs: new value "dynamic"
Do you want to set "pm" to the old value "static"? (Y/n) y
Changed pm from "dynamic" to "static"

The value for "pm.max_children" differs: new value "5"
Do you want to set "pm.max_children" to the old value "39"? (Y/n) y
Changed pm.max_children from "5" to "39"

The value for "pm.start_servers" differs: new value "2"
Do you want to set "pm.start_servers" to the old value "4"? (Y/n) y
Changed pm.start_servers from "2" to "4"

The value for "pm.min_spare_servers" differs: new value "1"
Do you want to set "pm.min_spare_servers" to the old value "4"? (Y/n) y
Changed pm.min_spare_servers from "1" to "4"

The value for "pm.max_spare_servers" differs: new value "3"
Do you want to set "pm.max_spare_servers" to the old value "8"? (Y/n) y
Changed pm.max_spare_servers from "3" to "8"

The value for "pm.max_children" is not set
Do you want to set "pm.max_children" with the old value "39"? (Y/n) y
Setting "pm.max_children = 39" added after line 111 in /etc/php/8.2/fpm/pool.d/www.conf

The value for "pm.max_spare_servers" is not set
Do you want to set "pm.max_spare_servers" with the old value "8"? (Y/n) y
Setting "pm.max_spare_servers = 8" added after line 103 in /etc/php/8.2/fpm/pool.d/www.conf

The value for "pm.min_spare_servers" is not set
Do you want to set "pm.min_spare_servers" with the old value "4"? (Y/n) y
Setting "pm.min_spare_servers = 4" added after line 99 in /etc/php/8.2/fpm/pool.d/www.conf

The value for "pm.start_servers" is not set
Do you want to set "pm.start_servers" with the old value "4"? (Y/n) y
Setting "pm.start_servers = 4" added after line 98 in /etc/php/8.2/fpm/pool.d/www.conf

The value for "pm.status_path" is not set
Do you want to set "pm.status_path" with the old value "/status"? (Y/n) y
Setting "pm.status_path = /status" added after line 267 in /etc/php/8.2/fpm/pool.d/www.conf

The value for "slowlog" is not set
Do you want to set "slowlog" with the old value "log/$pool.log.slow"? (Y/n) y
Setting "slowlog = log/$pool.log.slow" added after line 385 in /etc/php/8.2/fpm/pool.d/www.conf
pi@home:~ $ for linkgroup in `ls /var/lib/dpkg/alternatives/ | grep -E "ph(ar|p)"`; do sudo update-alternatives --config $linkgroup; done
Il existe 2 choix pour l'alternative phar (qui fournit /usr/bin/phar).

  Sélection   Chemin            Priorité  État
------------------------------------------------------------
* 0            /usr/bin/phar8.2   82        mode automatique
  1            /usr/bin/phar7.3   73        mode manuel
  2            /usr/bin/phar8.2   82        mode manuel

Appuyez sur <Entrée> pour conserver la valeur par défaut[*] ou choisissez le numéro sélectionné :
Il existe 2 choix pour l'alternative phar.phar (qui fournit /usr/bin/phar.phar).

  Sélection   Chemin                 Priorité  État
------------------------------------------------------------
* 0            /usr/bin/phar.phar8.2   82        mode automatique
  1            /usr/bin/phar.phar7.3   73        mode manuel
  2            /usr/bin/phar.phar8.2   82        mode manuel

Appuyez sur <Entrée> pour conserver la valeur par défaut[*] ou choisissez le numéro sélectionné :
Il existe 2 choix pour l'alternative php (qui fournit /usr/bin/php).

  Sélection   Chemin           Priorité  État
------------------------------------------------------------
* 0            /usr/bin/php8.2   82        mode automatique
  1            /usr/bin/php7.3   73        mode manuel
  2            /usr/bin/php8.2   82        mode manuel

Appuyez sur <Entrée> pour conserver la valeur par défaut[*] ou choisissez le numéro sélectionné :
Il n'existe qu'une « alternative » dans le groupe de liens phpdbg (qui fournit /usr/bin/phpdbg) : /usr/bin/phpdbg8.2
Rien Ă  configurer.
Il existe 2 choix pour l'alternative php-fpm.sock (qui fournit /run/php/php-fpm.sock).

  Sélection   Chemin                    Priorité  État
------------------------------------------------------------
* 0            /run/php/php8.2-fpm.sock   82        mode automatique
  1            /run/php/php7.3-fpm.sock   73        mode manuel
  2            /run/php/php8.2-fpm.sock   82        mode manuel

Appuyez sur <Entrée> pour conserver la valeur par défaut[*] ou choisissez le numéro sélectionné :
pi@home:~ $

That may be, because you may not yet have done this step:

You did not provide any information about the webserver you are using, so I am unable to help you with that step.

much luck!

Could you please tell me how I can give you the information. Normally I use the server that nextcloudpi has configured by default.

No, I can not do that. I’m not familiar with Nextcloud PI at all. I’ve already said that.

But there are many here in the forum who know exactly what to do and would like to help you further.

According to GitHub - nextcloud/nextcloudpi: 📦 Build code for NextcloudPi: Raspberry Pi, Odroid, Rock64, Docker, curl installer...

it is served by apache2.

On a debian Server this is what you have to do:

sudo a2disconf php7.3-fpm
sudo a2enconf php8.2-fpm
sudo systemctl restart apache2 php8.2-fpm

But again, I am no nextcloudpi expert!

much luck!

I’ll try to find out more and then post a message here

thank you very much, it’s an apache2 server.
I’ve applied the commands, but I still have a problem
when I go to nextcloud, I get the error:

This version of Nextcloud is not compatible with > PHP 8.0.
You are currently running 8.2.8.

when I try to update nextcloud, I get the following error:

Running nc-update-nextcloud
/usr/local/etc/library.sh: ligne 470 : [:  : nombre entier attendu comme expression
PHP:  syntax error, unexpected '"' in /etc/php/8.2/cli/php.ini on line 1979
Nextcloud is currently down
Done. Press any key...

I’ll see if I can find a solution

Unfortunately I haven’t found a solution.
Does anyone know where to look?

Then is this what you could do:

Look back all the steps you did to enable php8.2 and repeat it now for php8.0:

Install exactly the packages and sapi versions for version 8.0 that you have now installed for version 7.3:

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

migrate all settings from 7.3 to 8.0.

sudo php-updater 7.3 8.0

Switch all php-Packages with the update-alternative mechanism to use “manual 8.0”:

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

And finaly you do:

sudo a2disconf php8.2-fpm
sudo a2enconf php8.0-fpm
sudo systemctl restart apache2 php8.2-fpm

Much luck!

Thank you for being so patient with me.
Unfortunately, I always get the error

Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

and when updating

Running nc-update-nextcloud
PHP:  syntax error, unexpected '"' in /etc/php/8.0/cli/php.ini on line 1948
Nextcloud is currently down
Done. Press any key...

it looks like I’m doomed to remain in php 7.3

Looks like you are still on Debian 10.
This looks like you didn’t update your OS a long time.

You can enter post here the output of the command “ncp-report”. This should show all necessary log files.

If you have a up to date ncp system you should be in Debian 11 with php 8.1

1 Like

Thank you REAPERSbattlecry for taking an interest in my problem.
I put the code in an attached text file because the report contains too many characters.
ncp-rapport.odt (13,4 Ko)

What version of raspberry pi do you use?

To be honest. I’ll recommend a new set up and installation of ncp on your raspberry.
The reason are as already mentioned you are on an old raspian / debian version.

Second and even bigger issue is that you still using a 32 bit OS. This could be an issue.
So if you are using a raspberry pi which is capable of 64 bit I would go for the big step.

1 Like

Hi, I have a raspberry pi 4, which supports 64 bit.
The problem is that I use deck for my work and I have a huge number of cards and a lot of users that I can’t lose.
I’ve already tried updating in different ways but each time I get errors that prevent me from having a functional nextcloud.


If you do a search with my username, you’ll notice that it’s not because I don’t want to update my nextcloud.
Unfortunately, every time I get stuck, no solution is found.

Then I assume you already have a proper backup and migration strategy in place, otherwise you will eventually lose data!

Ask yourself the following questions:

  • How do I back up my data in a way that I can get it back if I need to rebuild the system?

  • How can I migrate to a new system without losing data?

If you can’t answer these questions, you must definitely not host important data exclusively on this system, and certainly not any data from third parties!

I mean what are you going to do if the SD card, SSD, or device itself dies?