NCP 1.50.5: PHP version 8.2 problem - how to downgrade?

Hi,
yesterday I did a system upgrade via sudo apt-upgrade and it seems that did damage my NCP installation on a Raspberry Pi.
Debian GNU/Linux 11. 5.15.84-v8+ (aarch64)

Current Nextcloud version 24.0.5.1

Problem:

This version of Nextcloud is not compatible with PHP>=8.2.
You are currently running 8.2.1.This version of Nextcloud is not compatible with PHP>=8.2.

The installed versions llok like this:

$ dpkg --get-selections | grep php
php-common                                      install
php-json                                        install
php8.1                                          install
php8.1-bcmath                                   install
php8.1-bz2                                      install
php8.1-cli                                      install
php8.1-common                                   install
php8.1-curl                                     install
php8.1-fpm                                      install
php8.1-gd                                       install
php8.1-gmp                                      install
php8.1-igbinary                                 install
php8.1-intl                                     install
php8.1-ldap                                     install
php8.1-mbstring                                 install
php8.1-mysql                                    install
php8.1-opcache                                  install
php8.1-readline                                 install
php8.1-redis                                    install
php8.1-xml                                      install
php8.1-zip                                      install
php8.2-cli                                      install
php8.2-common                                   install
php8.2-opcache                                  install
php8.2-phpdbg                                   install
php8.2-readline                                 install

I am not aware I did install PHP 8.2 yesterday, but now it is like it is.
I did use “sudo apt upgrade” as usually is recommended to keep the system up to date.

Since I am a technical noob I really do not know how to fix this.
I guess I need to uninstall the v8.2 items somehow and make NCP use the v8.1, right?

Any instructions on how to do this?

1 Like

Without being an expert either, from my experience with the same problem it was something like:

sudo apt remove php8.2-cli php8.2-common php8.2-opcache php8.2-phpdbg php8.2-readline

After that you restart your server (just to make it easy, restarting the services might also be enough). You got all the packages installed as v8.1as well, you don’t have to reinstall them.

I hope it works or otherwise someone else can help you out with the linux commands.

If you want to prevent sudo apt upgrade to install anything PHP-related to 8.2 you should google for apt hold.

Thanks. Now it looks like:

$ dpkg --get-selections | grep php
php-common                                      install
php8.1                                          install
php8.1-bcmath                                   install
php8.1-bz2                                      install
php8.1-cli                                      install
php8.1-common                                   install
php8.1-curl                                     install
php8.1-fpm                                      install
php8.1-gd                                       install
php8.1-gmp                                      install
php8.1-igbinary                                 install
php8.1-intl                                     install
php8.1-ldap                                     install
php8.1-mbstring                                 install
php8.1-mysql                                    install
php8.1-opcache                                  install
php8.1-readline                                 install
php8.1-redis                                    install
php8.1-xml                                      install
php8.1-zip                                      install
php8.2-cli                                      deinstall
php8.2-common                                   deinstall
php8.2-opcache                                  deinstall
php8.2-phpdbg                                   deinstall
php8.2-readline                                 deinstall

Sadly NC is still down after a reboot.

The log only says

[ nc-limits ] (Wed 18 Jan 10:38:31 CET 2023)
Using 6143880192 for PHP max memory
Installing template ‘php/90-ncp.ini.sh’…
Using 6 PHP threads
Installing template ‘php/pool.d.www.conf.sh’…
Installing template ‘mysql/91-ncp.cnf.sh’…

From the control panel I manually started “nc-previews” and it throws:

[ nc-previews ] (Wed Jan 18 10:47:40 CET 2023)
Cannot load Zend OPcache - it was already loaded
Cannot load Zend OPcache - it was already loaded
Cannot load Zend OPcache - it was already loaded
Cannot load Zend OPcache - it was already loaded
An unhandled exception has been thrown:
OCP\HintException: [0]: Memcache \OC\Memcache\Redis not available for local cache (Is the matching PHP module installed and enabled?)
An unhandled exception has been thrown:
OCP\HintException: [0]: Memcache \OC\Memcache\Redis not available for local cache (Is the matching PHP module installed and enabled?)
An unhandled exception has been thrown:
OCP\HintException: [0]: Memcache \OC\Memcache\Redis not available for local cache (Is the matching PHP module installed and enabled?)
An unhandled exception has been thrown:
OCP\HintException: [0]: Memcache \OC\Memcache\Redis not available for local cache (Is the matching PHP module installed and enabled?)

So I fear something else needs to be done. Any hints?

Can you try with sudo apt remove php-json php8.2-* and see if that works?

It should remove the packages causing issues

Please read what it’s trying to remove carefully so it doesn’t remove something else other than php 8.2 & php-json packages :pray:

1 Like

Since I already removed v8.2 before (see my previous posts) that did not improve the situation.

As last resort I now completely removed all PHP via
sudo apt remove --purge -y php* --allow-change-held-packages && apt autoremove -y

Then I did a fresh install of PHP 8.1 via
sudo apt install php8.1-{fpm,gd,curl,xml,zip,intl,mbstring,bz2,ldap,apcu,bcmath,gmp,imagick,igbinary,mysql,redis,smbclient,cli,common,opcache,readline}

Then I did all of the following:

Um PHP an ihr System anzupassen werden einige Parameter berechnet, führen Sie die nachfolgenden Zeilen einfach aus:

AvailableRAM=$(awk ‘/MemAvailable/ {printf “%d”, $2/1024}’ /proc/meminfo)
AverageFPM=$(ps --no-headers -o ‘rss,cmd’ -C php-fpm8.1 | awk ‘{ sum+=$1 } END { printf (“%d\n”, sum/NR/1024,“M”) }’)
FPMS=$((AvailableRAM/AverageFPM))
PMaxSS=$((FPMS*2/3))
PMinSS=$((PMaxSS/2))
PStartS=$(((PMaxSS+PMinSS)/2))

Führen Sie nun alle nachfolgenden Befehle zur Optimierung von PHP aus:

sed -i “s/;env[HOSTNAME] = /env[HOSTNAME] = /” /etc/php/8.1/fpm/pool.d/www.conf
sed -i “s/;env[TMP] = /env[TMP] = /” /etc/php/8.1/fpm/pool.d/www.conf
sed -i “s/;env[TMPDIR] = /env[TMPDIR] = /” /etc/php/8.1/fpm/pool.d/www.conf
sed -i “s/;env[TEMP] = /env[TEMP] = /” /etc/php/8.1/fpm/pool.d/www.conf
sed -i “s/;env[PATH] = /env[PATH] = /” /etc/php/8.1/fpm/pool.d/www.conf
sed -i ‘s/pm = dynamic/pm = static/’ /etc/php/8.1/fpm/pool.d/www.conf
sed -i ‘s/pm.max_children =./pm.max_children = ‘$FPMS’/’ /etc/php/8.1/fpm/pool.d/www.conf
sed -i 's/pm.start_servers =.
/pm.start_servers = ‘$PStartS’/’ /etc/php/8.1/fpm/pool.d/www.conf
sed -i ‘s/pm.min_spare_servers =./pm.min_spare_servers = ‘$PMinSS’/’ /etc/php/8.1/fpm/pool.d/www.conf
sed -i 's/pm.max_spare_servers =.
/pm.max_spare_servers = ‘$PMaxSS’/’ /etc/php/8.1/fpm/pool.d/www.conf
sed -i “s/;pm.max_requests =./pm.max_requests = 1000/" /etc/php/8.1/fpm/pool.d/www.conf
sed -i "s/allow_url_fopen =.
/allow_url_fopen = 1/” /etc/php/8.1/fpm/php.ini

sed -i “s/output_buffering =./output_buffering = ‘Off’/" /etc/php/8.1/cli/php.ini
sed -i "s/max_execution_time =.
/max_execution_time = 3600/” /etc/php/8.1/cli/php.ini
sed -i “s/max_input_time =./max_input_time = 3600/" /etc/php/8.1/cli/php.ini
sed -i "s/post_max_size =.
/post_max_size = 10240M/” /etc/php/8.1/cli/php.ini
sed -i “s/upload_max_filesize =./upload_max_filesize = 10240M/" /etc/php/8.1/cli/php.ini
sed -i "s/;date.timezone.
/date.timezone = Europe/\Berlin/” /etc/php/8.1/cli/php.ini
sed -i “s/;cgi.fix_pathinfo.*/cgi.fix_pathinfo=0/” /etc/php/8.1/cli/php.ini

sed -i “s/memory_limit = 128M/memory_limit = 1G/” /etc/php/8.1/fpm/php.ini
sed -i “s/output_buffering =./output_buffering = ‘Off’/" /etc/php/8.1/fpm/php.ini
sed -i "s/max_execution_time =.
/max_execution_time = 3600/” /etc/php/8.1/fpm/php.ini
sed -i “s/max_input_time =./max_input_time = 3600/" /etc/php/8.1/fpm/php.ini
sed -i "s/post_max_size =.
/post_max_size = 10G/” /etc/php/8.1/fpm/php.ini
sed -i “s/upload_max_filesize =./upload_max_filesize = 10G/" /etc/php/8.1/fpm/php.ini
sed -i "s/;date.timezone.
/date.timezone = Europe/\Berlin/” /etc/php/8.1/fpm/php.ini
sed -i “s/;cgi.fix_pathinfo./cgi.fix_pathinfo=0/" /etc/php/8.1/fpm/php.ini
sed -i "s/;session.cookie_secure.
/session.cookie_secure = True/” /etc/php/8.1/fpm/php.ini
sed -i “s/;opcache.enable=./opcache.enable=1/" /etc/php/8.1/fpm/php.ini
sed -i "s/;opcache.validate_timestamps=.
/opcache.validate_timestamps=0/” /etc/php/8.1/fpm/php.ini
sed -i “s/;opcache.enable_cli=./opcache.enable_cli=1/" /etc/php/8.1/fpm/php.ini
sed -i "s/;opcache.memory_consumption=.
/opcache.memory_consumption=256/” /etc/php/8.1/fpm/php.ini
sed -i “s/;opcache.interned_strings_buffer=./opcache.interned_strings_buffer=32/" /etc/php/8.1/fpm/php.ini
sed -i "s/;opcache.max_accelerated_files=.
/opcache.max_accelerated_files=100000/” /etc/php/8.1/fpm/php.ini
sed -i “s/;opcache.revalidate_freq=./opcache.revalidate_freq=60/" /etc/php/8.1/fpm/php.ini
sed -i "s/;opcache.save_comments=.
/opcache.save_comments=1/” /etc/php/8.1/fpm/php.ini

sed -i “s|;emergency_restart_threshold.|emergency_restart_threshold = 10|g" /etc/php/8.1/fpm/php-fpm.conf
sed -i "s|;emergency_restart_interval.
|emergency_restart_interval = 1m|g” /etc/php/8.1/fpm/php-fpm.conf
sed -i “s|;process_control_timeout.*|process_control_timeout = 10|g” /etc/php/8.1/fpm/php-fpm.conf

sed -i ‘$aapc.enable_cli=1’ /etc/php/8.1/mods-available/apcu.ini

source: https://www.c-rieger.de/upgrade-nextcloud/#PHPUpgrade

And restarted via:
systemctl restart php8.1-fpm.service mariadb.service redis-server.service

Good news: my NC seems to be back up again.

Thanks so much for posting, I had exactly the same problem.

Where did you get this list from what php settings needs to be adjusted?

I tried to apply the sed commands on my current (broken) install - and not on a fresh one as you suggested, and this resulted in invalid php config files I had to roll back …

And looking at the apt logs I noticed that I didn’t have apcu and smbclient installed before. Are those required to run the nextcloud?

I googled around and found this here:
https://www.c-rieger.de/upgrade-nextcloud/#PHPUpgrade

I had the impression that after uninstallting the v8.2 pieces there was some mixed situation still, so I aimed at wiping off all PHP stuff and reinstall it.

I am an incompetent fool to ask. I just did what seemed to look like a reasonable recommendation from the linked website.
My gut feeling is that smbclient is not needed and apcu neither, since redis is an alternative.
According to the documentation (Memory caching — Nextcloud latest Administration Manual latest documentation) both redis and apcu are valid caching tools.

I figured it would not hurt much to install a few extra components. And as my NC is up again, that seems correct.

Thanks again, it seems, the ncp is again working (except of WebDAV)

I am having trouble, I had the error, installed with the commands in this post and now when I log in into the page I only see some php code, not he website. When I check apache2 errors I see nothing. Any idea what is wrong?

Did you then also remove the previous PHP 8.2 installation?

Did you first wipe all previous PHP installation stuff with:

What you describe sounds like there is a mixture of things.

With

dpkg --get-selections | grep php

you can see what you have at any time.

Yes, the problem was missing libapache2-mod-php8.1. After this was installed all worked.

1 Like

Thanks to the hints here I got my nextcloud (more or less) running again (after I also accidentally updated php to 8.2) - except for WebDAV. And I see a lot of error messages in /var/log/apache2/nc-error.log:

[Mon Jan 23 21:20:27.824911 2023] [proxy_fcgi:error] [pid 81807:tid 548470358400] [client 192.168.178.34:60606] AH01071: Got error 'Access to the script 'redirect:/index.php/' has been denied (see security.limit_extensions)'
[Mon Jan 23 21:20:40.002779 2023] [proxy_fcgi:error] [pid 81807:tid 548470358400] [client 192.168.178.34:55144] AH01071: Got error 'Access to the script 'redirect:/index.php/v1/heartbeat' has been denied (see security.limit_extensions)'
[Mon Jan 23 21:20:41.034108 2023] [proxy_fcgi:error] [pid 81807:tid 548470358400] [client 192.168.178.34:55144] AH01071: Got error 'Access to the script 'redirect:/index.php/v1/heartbeat' has been denied (see security.limit_extensions)'
[Mon Jan 23 21:20:42.268320 2023] [proxy_fcgi:error] [pid 81807:tid 548470358400] [client 192.168.178.34:55144] AH01071: Got error 'Access to the script 'redirect:/index.php/v1/heartbeat' has been denied (see security.limit_extensions)'
[Mon Jan 23 21:20:48.907133 2023] [proxy_fcgi:error] [pid 81807:tid 548386414976] [client 192.168.178.34:58290] AH01071: Got error 'Access to the script 'redirect:/index.php/providers' has been denied (see security.limit_extensions)'
[Mon Jan 23 21:20:50.092618 2023] [proxy_fcgi:error] [pid 81807:tid 548386414976] [client 192.168.178.34:58290] AH01071: Got error 'Access to the script 'redirect:/index.php/v1/heartbeat' has been denied (see security.limit_extensions)'
[Mon Jan 23 21:20:50.181093 2023] [proxy_fcgi:error] [pid 81807:tid 548386414976] [client 192.168.178.34:58290] AH01071: Got error 'Access to the script 'redirect:/index.php/v2/notifications' has been denied (see security.limit_extensions)'
[Mon Jan 23 21:20:50.188409 2023] [proxy_fcgi:error] [pid 81807:tid 548386414976] [client 192.168.178.34:58290] AH01071: Got error 'Access to the script 'redirect:/index.php/v1/heartbeat' has been denied (see security.limit_extensions)'

I searched all php config files for security.limit_extensions but I didn’t find any configuration. Do I need to put this somewhere?

Maybe some more details about my WebDAV issue. I updated to 25.0.3 (using ncp-config) but the issues remained.

When I go to /settings/admin/overview it says:

There are some errors regarding your setup.

    Your web server is not yet properly set up to allow file synchronization, because the WebDAV interface seems to be broken.

    Your web server is not properly set up to resolve "/.well-known/caldav". Further information can be found in the documentation ↗.
    Your web server is not properly set up to resolve "/.well-known/carddav". Further information can be found in the documentation ↗.

Please double check the installation guides ↗, and check for any errors or warnings in the log. 

I looked at the documentation that is referred to https://docs.nextcloud.com/server/25/go.php?to=admin-setup-well-known-URL and https://docs.nextcloud.com/server/25/go.php?to=admin-install but didn’t find something that helped. (Maybe I missed something?)

When I try to access https://nextcloudpi.local/remote.php/dav/ in the browser it simply says:

Access denied.

(instead of This is the WebDAV interface. It can only be accessed by WebDAV clients such as the Nextcloud desktop sync client.) and this causes another

[Mon Jan 23 21:37:34.996196 2023] [proxy_fcgi:error] [pid 81808:tid 548403216768] [client 192.168.178.34:44726] AH01071: Got error 'Access to the script 'redirect:/index.php/' has been denied (see security.limit_extensions)' error to appear in the log.

Hi peter3,

I do not have a solution for your problem but I can share a weird story:

  1. When I read what you wrote, I checked if my own webdav was still working. It did.
  2. 2 days ago my NCP was auto updated to 1.51
  3. Yesterday morning I was happily chaning calender entries and they got replicated
  4. Today I saw HPB service was down and I couldnt log back in at all to NC while the NCP panel was still working
  5. I did a reboot from NCP panel and HPB service was up again and I could log back into NC as a user
  6. Today I saw that sometime around lunch yesterday (when I was not using NC at all and it was up and running, no updates going on) suddenly I also saw WebDAV errors. And I couldnt even open up the Calendar in the browser.
  7. I did some more reboots but that did not improve anything
  8. Then via ncp-config on the shell I froced the update to NC 25.0.3
  9. After that logging into NC was impossible again and no reboots fixed it. HPB down again.
  10. Then as a last resort I walked to my Raspi physically and unplugged the power and restarted it.
  11. Believe it or not, system is up again, HPB works, I can log in, WebDAV is working again.

It all sounds completely illogical, but that is the story.

Oh, really a strange story. But, yes, sometimes a real physical power off is helpful. (I did try this a couple of times without any positive effect.)

BTW: What ist actually the HPB service? It’s also down on my ncp.

It is the high performance backend introduced with NC 21
https://nextcloud.com/blog/nextcloud-faster-than-ever-introducing-files-high-performance-back-end/

1 Like

In then meantime my instance was down again overnight.
HPB was down.
Another physical hard reset solved it - again.

This fixed a similar issue on my end :slight_smile:

1 Like

For documentation let me add that I now have issued the command
sudo apt-mark hold php
which blocks future - unintended - upgrading of PHP. Just the thing that started all this mess.
see: https://www.computerhope.com/unix/apt-mark.htm

2 Likes