Nextcloud 27 on Ubuntu 20.04 (no snap), error with occ command after upgrading PHP version from 7.4 to 8.1

Nextcloud version: 27
Operating system and version: Ubuntu 20.04 LTS (no snap)
Apache or nginx version: Apache/2.4.41 (Ubuntu)
PHP version: 8.1

The issue you are facing:

I have updated PHP from version 7.4, to version 8.1, and I uninstalled the old 7.4. I configured the /etc/php/8.1/apache2/php.ini file, and I have installed the 8.1 modules, but when I try to run occ command I get the error:

sudo -u www-data php -f /var/www/nextcloud/cron.php

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:140
Stack trace:
#0 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1531): OC\DB\Connection->connect() 
[...]

Also the cron job return the same error.

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Update PHP from 7.4 to 8.1
  2. Install all the PHP modules
  3. Try to run an occ command

The output of your Nextcloud log in Admin > Logging:

Debug	logreader	Could not find resource file "/apps/logreader/css/../js/logreader-main.css"	
2023-07-02T12:54:48+0200

Info	no app in context	InvalidArgumentException: Section with the same ID already registered: migration, class: OCA\Google\Settings\PersonalSection	
2023-07-02T12:54:48+0200

Debug	no app in context	Deprecated event type for OCP\IDBConnection::CHECK_MISSING_COLUMNS: Symfony\Component\EventDispatcher\GenericEvent is used	
2023-07-02T12:35:43+0200

Info	no app in context	InvalidArgumentException: Section with the same ID already registered: migration, class: OCA\Google\Settings\PersonalSection	
2023-07-02T12:35:32+0200

Debug	no app in context	Deprecated event type for OCP\IDBConnection::CHECK_MISSING_COLUMNS: Symfony\Component\EventDispatcher\GenericEvent is used	
2023-07-02T12:35:25+0200

Debug	no app in context	Deprecated event type for OCP\IDBConnection::CHECK_MISSING_INDEXES: Symfony\Component\EventDispatcher\GenericEvent is used	
2023-07-02T12:35:25+0200

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

 <?php
$CONFIG = array (
  'instanceid' => '*******',
  'passwordsalt' => '*******',
  'secret' => '*******',
  'trusted_domains' => 
  array (
    0 => 'name.mydomain.com',
  ),
  'datadirectory' => '/home/mynextdata/',
  'dbtype' => 'mysql',
  'version' => '27.0.0.8',
  'overwrite.cli.url' => 'http://name.mydomain.com',
  'dbname' => 'nextclouddb',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextclouduser',
  'dbpassword' => '*******',
  'installed' => true,
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 0,
  'default_phone_region' => 'IT',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'mail_smtpmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_sendmailmode' => 'smtp',
  'mail_smtpauth' => 1,
  'mail_smtpsecure' => 'tls',
  'mail_from_address' => 'myemailgmail',
  'mail_domain' => 'gmail.com',
  'mail_smtphost' => 'smtp.googlemail.com',
  'mail_smtpport' => '587',
  'mail_smtpname' => 'myemailgmail',
  'mail_smtppassword' => '*******',
  'twofactor_enforced' => 'false',
  'twofactor_enforced_groups' => 
  array (
    0 => 'Home',
  ),
  'twofactor_enforced_excluded_groups' => 
  array (
    0 => 'admin',
  ),
  'updater.release.channel' => 'stable',
  'updater.secret' => '*******',
  'memories.exiftool' => '/var/www/nextcloud/apps/memories/exiftool-bin/exiftool-amd64-glibc',
  'memories.vod.path' => '/var/www/nextcloud/apps/memories/exiftool-bin/go-vod-amd64',
  'preview_max_memory' => 4096,
  'preview_max_filesize_image' => 256,
  'enabledPreviewProviders' => 
  array (
    0 => 'OC\\Preview\\Image',
  ),
  'preview_max_x' => 512,
  'preview_max_y' => 512,
);

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

[Sun Jul 02 00:00:07.829147 2023] [mpm_prefork:notice] [pid 51410] AH00163: Apache/2.4.41 (Ubuntu) OpenSSL/1.1.1f configured -- resuming normal operations
[Sun Jul 02 00:00:07.829190 2023] [core:notice] [pid 51410] AH00094: Command line: '/usr/sbin/apache2'
[Sun Jul 02 02:02:45.513006 2023] [php:error] [pid 61785] [client 68.***.***.229:47956] script '/var/www/html/upl.php' not found or unable to stat
[Sun Jul 02 02:02:46.637370 2023] [php:error] [pid 60770] [client 68.***.***.229:48004] script '/var/www/html/1.php' not found or unable to stat
[Sun Jul 02 06:37:18.629107 2023] [mpm_prefork:notice] [pid 51410] AH00171: Graceful restart requested, doing restart
[Sun Jul 02 06:37:18.730879 2023] [mpm_prefork:notice] [pid 51410] AH00163: Apache/2.4.41 (Ubuntu) OpenSSL/1.1.1f configured -- resuming normal operations
[Sun Jul 02 06:37:18.730895 2023] [core:notice] [pid 51410] AH00094: Command line: '/usr/sbin/apache2'
[Sun Jul 02 06:37:23.991032 2023] [mpm_prefork:notice] [pid 51410] AH00171: Graceful restart requested, doing restart
[Sun Jul 02 06:37:24.083945 2023] [mpm_prefork:notice] [pid 51410] AH00163: Apache/2.4.41 (Ubuntu) OpenSSL/1.1.1f configured -- resuming normal operations
[Sun Jul 02 06:37:24.083966 2023] [core:notice] [pid 51410] AH00094: Command line: '/usr/sbin/apache2'
[Sun Jul 02 07:53:54.385084 2023] [php:error] [pid 82859] [client 164.***.***.79:56858] script '/var/www/html/upl.php' not found or unable to stat
[Sun Jul 02 07:53:54.693923 2023] [php:error] [pid 82858] [client 164.***.***.79:56898] script '/var/www/html/1.php' not found or unable to stat

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

Error	PHP	Optional parameter $trustedServers declared before required parameter $groupManager is implicitly treated as a required parameter at /var/www/nextcloud/apps/dav/lib/CardDAV/SystemAddressbook.php#60	
2023-07-02T13:14:33+0200

Error	PHP	include(): Failed opening '/var/www/nextcloud/apps/unsplash/templates/partials/license.php' for inclusion (include_path='/var/www/nextcloud/3rdparty/pear/archive_tar:/var/www/nextcloud/3rdparty/pear/console_getopt:/var/www/nextcloud/3rdparty/pear/pear-core-minimal/src:/var/www/nextcloud/3rdparty/pear/pear_exception:/var/www/nextcloud/apps') at /var/www/nextcloud/lib/private/Template/Base.php#180	
2023-07-02T11:10:42+0200

Error	PHP	include(/var/www/nextcloud/apps/unsplash/templates/partials/license.php): Failed to open stream: No such file or directory at /var/www/nextcloud/lib/private/Template/Base.php#180	
2023-07-02T11:10:42+0200

Error	PHP	Optional parameter $trustedServers declared before required parameter $groupManager is implicitly treated as a required parameter at /var/www/nextcloud/apps/dav/lib/CardDAV/SystemAddressbook.php#60	
2023-07-01T21:27:09+0200

Thank you

Please paste the output of php -m and show us the modules you have installed.

Do you use SQlite?

Hi, thank you for your answer.

I’m using MariaDB, and below the output of php -m:

[PHP Modules]
apcu
calendar
Core
ctype
date
exif
FFI
fileinfo
filter
ftp
gettext
hash
iconv
imagick
json
libxml
openssl
pcntl
pcre
PDO
Phar
posix
random
readline
Reflection
session
shmop
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
Zend OPcache
zlib

[Zend Modules]
Zend OPcache

Thank you for your help.

Here’s a list containing the mudules i use for my Nextcloud instance.

Did you correctly configure APC? I remember having some trouble when using occ commands. Please make sure you have added apc.enable_cli=1 inside 20-apcu.ini. There should be several 20-apcu.ini files inside /etc/php/8.1/ [apache | cli | fpm] /conf.d/20-apcu.ini

20-apcu.ini should look like this:

extension=apcu.so
apc.enabled=1
apc.enable_cli=1

[PHP Modules]
apcu
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
igbinary
imagick
imap
intl
json
ldap
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pgsql
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

Dear @Michael2105 I checked, and in /etc/php/8.1/apache2/conf.d/20-apcu.ini those two lines where missing: apc.enabled=1 apc.enable_cli=1, instead the other two 20-apcu.ini (/cli and /fpm), were ok.

I restarted apache2, but I have the same error:

sudo -u www-data php -f /var/www/nextcloud/cron.php

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:140
Stack trace:
#0 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1531): OC\DB\Connection->connect()
#1 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1029): Doctrine\DBAL\Connection->getWrappedConnection()
#2 /var/www/nextcloud/lib/private/DB/Connection.php(262): 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(280): Doctrine\DBAL\Query\QueryBuilder->execute()
#5 /var/www/nextcloud/lib/private/AppConfig.php(418): 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(374): OC\AppConfig->getApps()
#8 /var/www/nextcloud/lib/private/legacy/OC_App.php(803): OC\AppConfig->getValues()
#9 /var/www/nextcloud/lib/private/Server.php(733): OC_App::getAppVersions()
#10 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): 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(138): Pimple\Container->offsetGet()
#13 /var/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#14 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#15 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(193): OC\AppFramework\Utility\SimpleContainer->get()
#16 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): 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(138): Pimple\Container->offsetGet()
#19 /var/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#20 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#21 /var/www/nextcloud/lib/private/Server.php(1115): OC\AppFramework\Utility\SimpleContainer->get()
#22 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): 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(138): Pimple\Container->offsetGet()
#25 /var/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#26 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#27 /var/www/nextcloud/lib/private/Server.php(2067): OC\AppFramework\Utility\SimpleContainer->get()
#28 /var/www/nextcloud/lib/private/Files/View.php(106): OC\Server->getLockingProvider()
#29 /var/www/nextcloud/lib/private/Server.php(467): OC\Files\View->__construct()
#30 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): 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(138): Pimple\Container->offsetGet()
#33 /var/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#34 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#35 /var/www/nextcloud/lib/private/Server.php(1469): OC\AppFramework\Utility\SimpleContainer->get()
#36 /var/www/nextcloud/lib/base.php(631): OC\Server->boot()
#37 /var/www/nextcloud/lib/base.php(1173): OC::init()
#38 /var/www/nextcloud/cron.php(43): require_once('...')
#39 {main}

Can you please install following php modules?

pdo_mysql
mysqlnd

Also please check you phpinfo for the driver

Dear @Michael2105, thank you for your reply, and sorry for my late answer.

I tried to install the modules “mysqlnd” and “pdo_mysql”, and I get this response:

srvadmin@www:~$ sudo apt install php8.1-mysqlnd
Reading package lists… Done
Building dependency tree
Reading state information… Done
Note, selecting ‘php8.1-mysql’ instead of ‘php8.1-mysqlnd’
php8.1-mysql is already the newest version (8.1.21-1+ubuntu20.04.1+deb.sury.org+1).
0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.

srvadmin@www:~$ sudo apt install php8.1-pdo_mysql
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package php8.1-pdo_mysql

This is the output of phpinfo, I get the PDO part:

Thank you

This is all I did to get this up and running (I use aptitude but it make no difference in regard to php module):

add-apt-repository ppa:ondrej/php
apt-get install aptitude -y
aptitude install apache2 php8.2-{cli,fpm,imagick,common,mysql,gd,json,curl,zip,xml,mbstring,bz2,intl,bcmath,gmp,dom,ldap,ctype,posix,pgsql} postgresql postgresql-client unzip ufw -y

It is the php8.2-mysql module that make this work for you. You do have to enable this module in php.ini if not done during installing though.

apt install php8.2-mysql

should be enough.

@Kerasit thank you for your answer.

I have added the repo ppa:ondrej/php, and when I execute the command: sudo apt-get install apache2 php8.2-{cli,fpm,imagick,common,mysql,gd,json,curl,zip,xml,mbstring,bz2,intl,bcmath,gmp,dom,ldap,ctype,posix,pgsql} postgresql postgresql-client unzip ufw -y

I get this response:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'php8.2-xml' instead of 'php8.2-dom'
Note, selecting 'php8.2-common' instead of 'php8.2-ctype'
Note, selecting 'php8.2-common' instead of 'php8.2-posix'
Package php8.2-json is a virtual package provided by:
  php8.2-phpdbg 8.2.9-1+ubuntu20.04.1+deb.sury.org+1
  php8.2-fpm 8.2.9-1+ubuntu20.04.1+deb.sury.org+1
  php8.2-cli 8.2.9-1+ubuntu20.04.1+deb.sury.org+1
  php8.2-cgi 8.2.9-1+ubuntu20.04.1+deb.sury.org+1
  libphp8.2-embed 8.2.9-1+ubuntu20.04.1+deb.sury.org+1
  libapache2-mod-php8.2 8.2.9-1+ubuntu20.04.1+deb.sury.org+1
You should explicitly select one to install.

E: Package 'php8.2-json' has no installation candidate

Should I change the packages name as suggested?

Thank you

Sorry the late answer.

-cgi, -fpm or libapache2-mod-php8.2 will be installed anyway, so just remove it from the install command.

And -fpm is only needed if you are planning to run the fastcgi PHP method instead of php as a module by apache itself.

pgsql is also only needed (no harm installing it though) if you will be running postgresql.

Hi,

I installed all the packages, removing the one return an error, this is the result:

sudo apt-get install apache2 php8.2-{cli,imagick,common,mysql,gd,curl,zip,xml,mbstring,bz2,intl,bcmath,gmp,dom,ldap,ctype,posix} unzip ufw -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'php8.2-xml' instead of 'php8.2-dom'
Note, selecting 'php8.2-common' instead of 'php8.2-ctype'
Note, selecting 'php8.2-common' instead of 'php8.2-posix'
apache2 is already the newest version (2.4.41-4ubuntu3.14).
ufw is already the newest version (0.36-6ubuntu1.1).
ufw set to manually installed.
unzip is already the newest version (6.0-25ubuntu1.1).
php8.2-cli is already the newest version (8.2.9-1+ubuntu20.04.1+deb.sury.org+1).
php8.2-cli set to manually installed.
php8.2-common is already the newest version (8.2.9-1+ubuntu20.04.1+deb.sury.org+1).
php8.2-common set to manually installed.
php8.2-imagick is already the newest version (3.7.0-3+ubuntu20.04.1+deb.sury.org+1).
php8.2-imagick set to manually installed.
The following NEW packages will be installed:
  php8.2-bcmath php8.2-bz2 php8.2-curl php8.2-gd php8.2-gmp php8.2-intl php8.2-ldap php8.2-mbstring php8.2-mysql php8.2-xml php8.2-zip
0 upgraded, 11 newly installed, 0 to remove and 6 not upgraded.
Need to get 977 kB of archives.
After this operation, 3615 kB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 php8.2-bcmath amd64 8.2.9-1+ubuntu20.04.1+deb.sury.org+1 [15.5 kB]
Get:2 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 php8.2-bz2 amd64 8.2.9-1+ubuntu20.04.1+deb.sury.org+1 [10.7 kB]
Get:3 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 php8.2-curl amd64 8.2.9-1+ubuntu20.04.1+deb.sury.org+1 [34.6 kB]
Get:4 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 php8.2-gd amd64 8.2.9-1+ubuntu20.04.1+deb.sury.org+1 [29.0 kB]
Get:5 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 php8.2-gmp amd64 8.2.9-1+ubuntu20.04.1+deb.sury.org+1 [22.9 kB]
Get:6 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 php8.2-intl amd64 8.2.9-1+ubuntu20.04.1+deb.sury.org+1 [139 kB]
Get:7 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 php8.2-ldap amd64 8.2.9-1+ubuntu20.04.1+deb.sury.org+1 [31.0 kB]
Get:8 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 php8.2-mbstring amd64 8.2.9-1+ubuntu20.04.1+deb.sury.org+1 [440 kB]
Get:9 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 php8.2-mysql amd64 8.2.9-1+ubuntu20.04.1+deb.sury.org+1 [117 kB]
Get:10 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 php8.2-xml amd64 8.2.9-1+ubuntu20.04.1+deb.sury.org+1 [110 kB]
Get:11 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 php8.2-zip amd64 8.2.9-1+ubuntu20.04.1+deb.sury.org+1 [26.3 kB]
Fetched 977 kB in 3s (312 kB/s)       
Selecting previously unselected package php8.2-bcmath.
(Reading database ... 138323 files and directories currently installed.)
Preparing to unpack .../00-php8.2-bcmath_8.2.9-1+ubuntu20.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php8.2-bcmath (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...
Selecting previously unselected package php8.2-bz2.
Preparing to unpack .../01-php8.2-bz2_8.2.9-1+ubuntu20.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php8.2-bz2 (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...
Selecting previously unselected package php8.2-curl.
Preparing to unpack .../02-php8.2-curl_8.2.9-1+ubuntu20.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php8.2-curl (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...
Selecting previously unselected package php8.2-gd.
Preparing to unpack .../03-php8.2-gd_8.2.9-1+ubuntu20.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php8.2-gd (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...
Selecting previously unselected package php8.2-gmp.
Preparing to unpack .../04-php8.2-gmp_8.2.9-1+ubuntu20.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php8.2-gmp (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...
Selecting previously unselected package php8.2-intl.
Preparing to unpack .../05-php8.2-intl_8.2.9-1+ubuntu20.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php8.2-intl (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...
Selecting previously unselected package php8.2-ldap.
Preparing to unpack .../06-php8.2-ldap_8.2.9-1+ubuntu20.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php8.2-ldap (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...
Selecting previously unselected package php8.2-mbstring.
Preparing to unpack .../07-php8.2-mbstring_8.2.9-1+ubuntu20.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php8.2-mbstring (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...
Selecting previously unselected package php8.2-mysql.
Preparing to unpack .../08-php8.2-mysql_8.2.9-1+ubuntu20.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php8.2-mysql (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...
Selecting previously unselected package php8.2-xml.
Preparing to unpack .../09-php8.2-xml_8.2.9-1+ubuntu20.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php8.2-xml (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...
Selecting previously unselected package php8.2-zip.
Preparing to unpack .../10-php8.2-zip_8.2.9-1+ubuntu20.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php8.2-zip (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...
Setting up php8.2-ldap (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...

Creating config file /etc/php/8.2/mods-available/ldap.ini with new version
Setting up php8.2-mysql (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...

Creating config file /etc/php/8.2/mods-available/mysqlnd.ini with new version

Creating config file /etc/php/8.2/mods-available/mysqli.ini with new version

Creating config file /etc/php/8.2/mods-available/pdo_mysql.ini with new version
Setting up php8.2-bz2 (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...

Creating config file /etc/php/8.2/mods-available/bz2.ini with new version
Setting up php8.2-bcmath (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...

Creating config file /etc/php/8.2/mods-available/bcmath.ini with new version
Setting up php8.2-zip (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...

Creating config file /etc/php/8.2/mods-available/zip.ini with new version
Setting up php8.2-mbstring (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...

Creating config file /etc/php/8.2/mods-available/mbstring.ini with new version
Setting up php8.2-intl (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...

Creating config file /etc/php/8.2/mods-available/intl.ini with new version
Setting up php8.2-curl (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...

Creating config file /etc/php/8.2/mods-available/curl.ini with new version
Setting up php8.2-xml (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...

Creating config file /etc/php/8.2/mods-available/dom.ini with new version

Creating config file /etc/php/8.2/mods-available/simplexml.ini with new version

Creating config file /etc/php/8.2/mods-available/xml.ini with new version

Creating config file /etc/php/8.2/mods-available/xmlreader.ini with new version

Creating config file /etc/php/8.2/mods-available/xmlwriter.ini with new version

Creating config file /etc/php/8.2/mods-available/xsl.ini with new version
Setting up php8.2-gmp (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...

Creating config file /etc/php/8.2/mods-available/gmp.ini with new version
Setting up php8.2-gd (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...

Creating config file /etc/php/8.2/mods-available/gd.ini with new version
Processing triggers for php8.2-phpdbg (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...
Processing triggers for php8.2-cli (8.2.9-1+ubuntu20.04.1+deb.sury.org+1) ...

I also installed php mysql, that was already updated:

sudo apt install php8.2-mysql
Reading package lists... Done
Building dependency tree       
Reading state information... Done
php8.2-mysql is already the newest version (8.2.9-1+ubuntu20.04.1+deb.sury.org+1).
0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.

I restarted Apache 2, and I tried to run the occ command, that return this error result:

sudo -u www-data php -f /var/www/nextcloud/cron.php
OCP\HintException: [0]: Memcache \OC\Memcache\APCu not available for local cache (Is the matching PHP module installed and enabled?)

I also checked the php.ini file using the nano editor, in: sudo nano /etc/php/8.2/apache2/php.ini, but it’s empty. The directory /etc/php/8.2/apache2 doesn’t exists. Instead for the version 8.1 it has content.

That is what’s inside 8.2 directory:

ls -la /etc/php/8.2 
total 20
drwxr-xr-x 5 root root 4096 Jul  1 16:43 .
drwxr-xr-x 5 root root 4096 Jul  1 16:43 ..
drwxr-xr-x 3 root root 4096 Jul  1 16:43 cli
drwxr-xr-x 2 root root 4096 Aug 20 11:17 mods-available
drwxr-xr-x 3 root root 4096 Jul  1 16:43 phpdbg

Thank you

Memcache \OC\Memcache\APCu not available for local cache (Is the matching PHP module installed and enabled?)

This is a classic on this forum. Gotta enable/allow opcache for CLI.

Add

opcache.enable_cli=1

to php.ini (just add it to the bottom of file).

Better yet: Find the Opcache.ini file (/etc/php/8.2/10-opcache.ini or something) and set it there, so all PHP engines (apache mod, FPM or CLI) is using the same config file.