I’m attempting to upgrade our 25.0.13 installation to 26 and beyond, but have hit the PHP version problem. Our install was running PHP 7.4.3, as reported by NC. Following guides, I’ve now managed to install PHP 8.1.31 on the host, and from a shell, this is the version now reported, so Linux seems happy. Inside NC though, it still insists the version is 7.4.3, and I can’t see how I force NC to use the new version. I thought it should be automatic based on the host version, but maybe not.
I think something has changed inside NC though, because it’s currently reporting that the background tasks can’t run, and I can run most OC commands either, which is likely to do with PHP.
Unfortunately you did not fill out the support template, so I dont know what Operating System your server is running.
If you are on Debian or Ubuntu, you should use → the php-updater script ← to do all php related tasks, such as update, downgrade and switch between versions.
Keep in mind, that you not only have to upgrade PHP but also tell your webserver to use it. Usually there is either a module loaded for it in Apache or you have an external PHP-FPM process which will be used with fcgi. In both cases you need to change the name of the module or PHP-FPM socket to use.
PHP-FPM usually is accessed using /var/run/php-fpm.sock for the default version of your distribibution and /var/run/php<version>-fpm.sock for a specific version (for example /var/run/php-fpm8.3.sock for PHP-FPM version 8.3. Your webserver should have a configuration which refers to that socket. In Apache there may be a configuration file for this which can be enabled using a2enconf - also see /etc/apache2/conf-available.
In NGINX PHP-FPM is usually configured as handler for specific URL patterns and most likely also a separate configuration file which is enabled for the Nextcloud website and has to be updated.
To get current PHP versions you may also see my guide here:
Also keep in mind, that PHP is already at version 8.4 and 8.1 will only get security updates until end of 2025. So maybe you should switch to PHP 8.3 to avoid the need of another update within 12 months.
And in the future maybe you make it a habit to do major upgrades of PHP and Ubuntu at least every 2 years (using do-release-upgrade and by upgrading to newer version from the Sury PPA) . If you don’t have many customizations, this is usually not a big problem.
Maybe you can better first change to Nextcloud 22.04 LTS.
Why not simply dist-upgrade from Ubuntu 20.04 LTS to Ubuntu 22.04 LTS?
Nextcloud 25 is EOL. Please upgrade to 26, 27, 28 and Nextcloud 29 or better Nextcloud 30. On Nextcloud 28 or 29 also dist-upgrade to Ubuntu 24.04 LTS if you do not want to use an external PHP source.