Nextcloud using different PHP version than apache

Nextcloud version: 24.0.6
Operating system and version: Debian 10
Apache or nginx version: Apache 2.4.38
PHP version: 8.1.11

The issue you are facing:
I have PHP version 8.1.11 installed and activated for apache (when I run a2enmod php8.1 it says that it is already enabled) but when I log in to nextcloud as an admin it says PHP version is 7.4.32 (which is also installed on my server).

Once I try to fix the missing database indices I get An unhandled exception has been thrown: OCP\HintException: [0]: Memcache \OC\Memcache\APCu not available for local cache (Is the matching PHP module installed and enabled?)

I have APCu module installed, but it is for PHP 8.1.

So how can I make Nextcloud use PHP 8.1?

Did you also install all the modules?

sudo apt install libapache2-mod-php8.1

If your apache2 runs on php8.1 and your nextcloud is on apache2, then it also should run php8.1?

Do you have an old version of php installed and the fpm is still on something lower?

make a “dpkg -l | grep php” to see all installed php packages and modules. And maybe get rid of older and unused ones?

When I run sudo apt install libapache2-mod-php8.1 I get “is already installed”.

I have a few older versions of PHP installed. Can I safely remove them if I have PHP 8?

I would say, this is a bit depending on your machine, what services or programs you have running there. If it is only Nextcloud, then I would go for it. Some other programs might still need an older version of it. Just check with dpkg whatever is installed. Just in case, you can always reinstall it.

Ok, by removing the older versions of PHP I got an internal server error. I opened up a new thread.

But that means, that your nextcloud was not really on php8, or it seems like it. Did you reinstall the other versions?

Do you really use Debian 10 (Buster).
Can you upgrade to Debian 11 (Bullseye) and use the default php packages?

Find the needed packages here (Nextcloud on Debian 11 installation guide). Maybe you can install the packages from another source with Debian 10.

Actually I thought about this because I did a Nextcloud backup just 2 days ago (and my Nextcloud wasn’t working anyway).

But do I really have to do a complete reinstall of Nextcloud?

Read backup and restore if you want make backup/restore.

Maybe you can uninstall all php8.1-stuff, dist-upgrade to Debian 11, install standard php 7.4 packages from Debian 11 and the needed php-packages see my link below and all works again. Remove all foreign sources.

You must not reinstall Nextcloud. Nextcloud 24.0.6 are only a lot of files, an apache2 conf and some data in MariaDB. Hopefully it works again after dist-upgrade but then with PHP 7.4.

Requirements Nextcloud 24 (PHP 7.4. from Debian 11 possible)
Requirements Nextcloud 25 (also PHP 7.4 from Debian 11 possible)

Alternatively you can solve your problem with PHP8.1.
But pretty stupid to use an “old” Debian 10 and a pretty new PHP8.1.

I am on Debian 11 with PHP 7.4 now.

Unfortunately I am still getting that internal server error described in this thread.