How to change PHP version

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version 25.0.5
Operating system and version Ubuntu 20.04
Apache or nginx version Apache 2.4.56
PHP version 7.4

The issue you are facing:

In the administration overview I get the message
" You are currently running PHP 7.4.33. Upgrade your PHP version to take advantage of performance and security updates provided by the PHP Group as soon as your distribution supports it."

I have installed PHP 8.0, 8.1 and 8.2. However, when I try to run something from console, like for instance sudo -u www-data php occ mainenance:mode on, I get the message
“This version of Nextcloud is not compatible with PHP>=8.2.
You are currently running 8.2.4.”

If I try sudo -u www-data php8.1 occ mainenance:mode on I get

An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: could not find driver in /var/www/nextcloud/lib/private/DB/Connection.php:139
Stack trace:
#0 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1519): OC\DB\Connection->connect()
#1 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1041): Doctrine\DBAL\Connection->getWrappedConnection()
#2 /var/www/nextcloud/lib/private/DB/Connection.php(261): Doctrine\DBAL\Connection->executeQuery()
#3 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\DB\Connection->executeQuery()
#4 /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(281): Doctrine\DBAL\Query\QueryBuilder->execute()
#5 /var/www/nextcloud/lib/private/AppConfig.php(419): OC\DB\QueryBuilder\QueryBuilder->execute()
#6 /var/www/nextcloud/lib/private/AppConfig.php(184): OC\AppConfig->loadConfigValues()
#7 /var/www/nextcloud/lib/private/AppConfig.php(375): OC\AppConfig->getApps()
#8 /var/www/nextcloud/lib/private/legacy/OC_App.php(967): OC\AppConfig->getValues()
#9 /var/www/nextcloud/lib/private/Server.php(725): OC_App::getAppVersions()
#10 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\Server->OC\{closure}()
#11 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#12 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(129): Pimple\Container->offsetGet()
#13 /var/www/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#14 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(57): OC\ServerContainer->query()
#15 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(184): OC\AppFramework\Utility\SimpleContainer->get()
#16 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#17 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#18 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(129): Pimple\Container->offsetGet()
#19 /var/www/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#20 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(57): OC\ServerContainer->query()
#21 /var/www/nextcloud/lib/private/Server.php(1119): OC\AppFramework\Utility\SimpleContainer->get()
#22 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\Server->OC\{closure}()
#23 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#24 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(129): Pimple\Container->offsetGet()
#25 /var/www/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#26 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(57): OC\ServerContainer->query()
#27 /var/www/nextcloud/lib/private/Server.php(2070): OC\AppFramework\Utility\SimpleContainer->get()
#28 /var/www/nextcloud/lib/private/Files/View.php(117): OC\Server->getLockingProvider()
#29 /var/www/nextcloud/lib/private/Server.php(462): OC\Files\View->__construct()
#30 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\Server->OC\{closure}()
#31 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#32 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(129): Pimple\Container->offsetGet()
#33 /var/www/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#34 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(57): OC\ServerContainer->query()
#35 /var/www/nextcloud/lib/private/Server.php(1472): OC\AppFramework\Utility\SimpleContainer->get()
#36 /var/www/nextcloud/lib/base.php(617): OC\Server->boot()
#37 /var/www/nextcloud/lib/base.php(1144): OC::init()
#38 /var/www/nextcloud/console.php(48): require_once('...')
#39 /var/www/nextcloud/occ(11): require_once('...')

The same occurs if I change PHP8.1 to PHP8.0. The only version that doesn’t give me any error is PHP7.4.

How can I get occ to accept PHP8.0 or PHP8.1?
Is this the first time you’ve seen this error? (Y/N):

Steps to replicate it:

  1. Just open the Administration page

The output of your Nextcloud log in Admin > Logging:

I see a lot of errors about Sabre/DAV but I don’t think they are related (I’ll ask another question about that).

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'passwordsalt' => 'TheSalt',
  'secret' => 'MySecret',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => 'andreacroci.ddns.net',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '25.0.5.1',
  'overwrite.cli.url' => 'https://localhost',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'ThePassword',
  'installed' => true,
  'instanceid' => 'ock5nretuga0',
  'maintenance' => false,
  'default_phone_region' => 'DE',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'mail_from_address' => 'myaddress',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'myprovider',
  'mail_smtpsecure' => 'ssl',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'theprovider',
  'mail_smtpport' => '465',
  'mail_smtpname' => 'myaddress',
  'mail_smtppassword' => 'ThePassword',
  'theme' => '',
  'loglevel' => 2,
);

The output of your Apache/nginx/system log in /var/log/____:

[Fri Mar 31 09:18:07.018286 2023] [access_compat:error] [pid 770779] [client 46.142.35.190:51744] AH01797: client denied by server configuration: /var/www/nextcloud/data/.ocdata

first, I would advice to completely remove the yet unneccesary php8.2:

apt-get remove --purge php8.2*

Then you should provide information about how your apache comunicates with php: with Apache Module, cgi or fpm

Please provide the output of

find /etc/php/7.4 -name "php.ini" -type f

ls -l /etc/apache2/conf-enabled | grep php

ls -l /etc/apache2/mods-enabled | grep php

and

dpkg -l | awk '/^ii/ {print $2}' | grep -i php7.4

to find that out.

With that information, it is easy to help you

1 Like

So, I spent the last 4 days installing a new server with OpenSUSE Tumbleweed and now I no longer have the problem. (I have others though) :grin:

I guess it would be better to delete this question, since it will never receive an answer and my solution is a little too “drastic” to be useful to the community.

It’s a bit like Windows. Either you try to solve the problems or you do a reinstallation. In any case, it is certain that you learn more with the first suggestion. That’s why you don’t need any expertise with Windows. :wink:

Try to understand Linux and Nextcloud better. Use test systems for this purpose, for example. Then maybe it will run better next time.

Maybe solution for your old problem (info for other users):
I think you missed some packages e.g. php-mysql / php8.1-mysql or it was missconfigurated (old packages not deleted).

apt install apache2 mariadb-server php php-cli php-fpm php-json php-intl php-imagick php-pdo php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath apache2 libapache2-mod-php -y
tutorial

Sorry, I didn’t tell the whole truth. I wasn’t coming from Windows, but from Ubuntu. In the last 13 years I have fired up Windows three times (and two times I wish I hadn’t).
Reasons to change where:

  • I was fed up with Canonical wanting me to create an account, although free, in order to give me more security updates.
  • I had the system to a point where a major maintenance was needed. I tried to upgrade to 22.04, but, as always, it didn’t work.
  • I had always wanted to try other distros anyway and this was a good excuse to do it.

I have to say: I start loving OpenSUSE, but it takes some getting used to it because some things are not the same (for instance the Apache document root is in /srv/www/htdocs instead of /var/www/ and the apache-user is wwwrun instead of www-data). Plus I decided that trying a new distro was not enough and I had to switch from Gnome to KDE too.
Result: 4 days of searching the Internet for “how do you do this, how do you do that?”
But now I’ve got it up and running and I can relax a little bit.
By the way: NextCloud is great!

1 Like

You might be interested in a quick check. On my Alma system:

# ls -l /srv
lrwxrwxrwx. 1 root root 8 May  4  2021 www -> /var/www
# ls -id /var/www/html
68224967 /var/www/html
# ls -id /srv/www/html
68224967 /srv/www/html

so in fact they are the same directory. Obviouslyhtml is not htdocs, but it’s the structure I’m looking at.

1 Like

Very interesting indeed. On mine:

$ ls -l /srv/
total 0
drwxr-xr-x 1 tftp tftp 0 Mar 19 17:17 tftpboot
drwxr-xr-x 1 root root 46 Apr 4 16:55 www

There doesn’t seem to be a symlink to /var. And

$ ls -l /var/
total 16
drwxr-xr-x 1 root root 128 Apr 2 09:51 adm
lrwxrwxrwx 1 root root 13 Mar 20 05:46 agentx → …/run/agentx
drwxr-xr-x 1 root root 186 Apr 4 07:35 cache
drwxr-xr-x 1 root root 0 Feb 14 16:50 crash
drwxr-xr-x 1 root root 6792 Apr 2 10:05 cuda-repo-opensuse15-12-1-local
drwxr-xr-x 1 root root 746 Apr 6 06:33 lib
lrwxrwxrwx 1 root root 9 Apr 2 09:46 lock → /run/lock
drwxr-xr-x 1 root root 788 Apr 7 00:00 log
lrwxrwxrwx 1 root root 10 Mar 22 23:09 mail → spool/mail
drwxr-xr-x 1 root root 0 Feb 14 16:50 opt
lrwxrwxrwx 1 root root 4 Apr 2 09:46 run → /run
drwxr-xr-x 1 root root 94 Apr 2 09:48 spool
drwxrwxrwt 1 root root 1358 Apr 7 00:00 tmp

There doesn’t seem to be a www under /var.

The magic world of linux: the more I learn, the less I know…

My original example was from Alma8.7, I’ve just checked Alma9.1 and it’s the same.

@Andyfc
I do not understand your problems with Ubuntu. But maybe Debian - the mother of Ubuntu - is your solution. 100% community distribution. No account needed. I think you also do not really need an account for Ubuntu.

@devnull
Thank you for the suggestion. I took that into consideration, along with Fedora and Arch, but after some pondering I decided to give OpenSUSE a try. I might choose Debian for the laptop, when it’s time to change.
I don’t think my problems with Ubuntu are worth discussing at length in a Nextcloud forum.

1 Like

19 posts were split to a new topic: Upgrade php 7.4 to 8.0 on Ubuntu