NextCloud does not seem to be finding defult version of php

Nextcloud version (eg, 20.0.5): was 20.0.14, tried to update to 21.0.9
Operating system and version (eg, Ubuntu 20.04): Ubuntu 18.04.6
Apache (eg, Apache 2.4.25): Server version: Apache/2.4.29 (Ubuntu)
PHP version (eg, 7.4): NextCloud thinks 7.2.34-30; Terminal says 7.4.30

The issue you are facing:

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

Steps to replicate it (this is what I did):

  1. Found NextCloud was not updating because I was running an old version of php (7.2)
  2. Updated php version with
    a. sudo add-apt-repository ppa:ondrej/php
    b. sudo apt update
    c. sudo apt install php7.4
  3. Somehow version got set to 8 dot something.
  4. Ran sudo update-alternatives --set php /usr/bin/php7.4
  5. Command line now says php version is 7.4.30.
  6. Updated NextCloud from command line to 21.0.9.
  7. rebooted server
  8. Now cannot access web interface.
  9. Just get a page that says (This version of Nextcloud requires at least PHP 7.3
    You are currently running 7.2.34-30+ubuntu18.04.1+deb.sury.org+1. Please update your PHP version.).

The output of your Nextcloud log in Admin > Logging (cannot access):

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

<?php
$CONFIG = array (
  'updatechecker' => false,
  'instanceid' => '[..]',
  'passwordsalt' => '[...]',
  'secret' => '[...]',
  'trusted_domains' => 
  array (
    0 => '[ip address]',
    1 => '[domain name]',
  ),
  'datadirectory' => '/data/ocdata',
  'overwrite.cli.url' => 'http://[ip address]/nextcloud',
  'dbtype' => 'mysql',
  'version' => '21.0.9.1',
  'dbname' => 'ocdb',
  'dbhost' => 'localhost',
  'dbtableprefix' => 'oc_',
  'dbuser' => '[...]',
  'dbpassword' => '[...]',
  'logtimezone' => 'UTC',
  'installed' => true,
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 1,
  'htaccess.RewriteBase' => '/nextcloud',
  'trashbin_retention_obligation' => '30, 370',
);

The output of your Apache/nginx/system log in /var/log/apache2/error.log:

[Wed Jun 22 09:39:44.372100 xxx2] [php7:notice] [pid 848] [client 192.168.0.xxx:33350] {"reqId":"OM4eno8AFpn65qmpGGBm","level":1,"time":"xxx2-06-22T16:39:44+00:00","remoteAddr":"192.168.0.xxx","user":"[name]","app":"no app in context","method":"GET","url":"/nextcloud/ocs/v2.php/apps/notifications/api/v2/notifications","message":{"Exception":"Symfony\\\\Component\\\\Routing\\\\Exception\\\\RouteNotFoundException","Message":"Unable to generate a URL for the named route \\"photos.page.index\\" as such route does not exist.","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/Route/Router.php","line":372,"function":"generate","class":"Symfony\\\\Component\\\\Routing\\\\Generator\\\\UrlGenerator","type":"->","args":["photos.page.index",[],1]},{"file":"/var/www/nextcloud/lib/private/URLGenerator.php","line":85,"function":"generate","class":"OC\\\\Route\\\\Router","type":"->","args":["photos.page.index",[]]},{"file":"/var/www/nextcloud/lib/private/NavigationManager.php","line":282,"function":"linkToRoute","class":"OC\\\\URLGenerator","type":"->","args":["photos.page.index"]},{"file":"/var/www/nextcloud/lib/private/NavigationManager.php","line":108,"function":"init","class":"OC\\\\NavigationManager","type":"->","args":[]},{"file":"/var/www/nextcloud/apps/theming/lib/ThemingDefaults.php","line":184,"function":"getAll","class":"OC\\\\NavigationManager","type":"->","args":["guest"]},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Defaults.php","line":263,"function":"getShortFooter","class":"OCA\\\\Theming\\\\ThemingDefaults","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/public/Defaults.php","line":169,"function":"getLongFooter","class":"OC_Defaults","type":"->","args":[]},{"file":"/var/www/nextcloud/core/templates/layout.guest.php","line":55,"function":"getLongFooter","class":"OCP\\\\Defaults","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/private/Template/Base.php","line":180,"args":["/var/www/nextcloud/core/templates/layout.guest.php"],"function":"include"},{"file":"/var/www/nextcloud/lib/private/Template/Base.php","line":150,"function":"load","class":"OC\\\\Template\\\\Base","type":"->","args":["/var/www/nextcloud/core/templates/layout.guest.php",null]},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Template.php","line":180,"function":"fetchPage","class":"OC\\\\Template\\\\Base","type":"->","args":[null]},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Template.php","line":211,"function":"fetchPage","class":"OC_Template","type":"->","args":[null]},{"file":"/var/www/nextcloud/lib/private/Template/Base.php","line":132,"function":"fetchPage","class":"OC_Template","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Template.php","line":273,"function":"printPage","class":"OC\\\\Template\\\\Base","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/base.php","line":666,"function":"printGuestPage","class":"OC_Template","type":"::","args":["","error",{"errors":[{"error":"Your data directory is invalid","hint":"Ensure there is a file called \\".ocdata\\" in the root of the data directory."}]}]},{"file":"/var/www/nextcloud/lib/base.php","line":1091,"function":"init","class":"OC","type":"::","args":[]},{"file":"/var/www/nextcloud/ocs/v1.php","line":33,"args":["/var/www/nextcloud/lib/base.php"],"function":"require_once"},{"file":"/var/www/nextcloud/ocs/v2.php","line":24,"args":["/var/www/nextcloud/ocs/v1.php"],"function":"require_once"}],"File":"/var/www/nextcloud/3rdparty/symfony/routing/Generator/UrlGenerator.php","Line":143,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:101.0) Gecko/20100101 Firefox/101.0","version":"20.0.14.2"}
[Wed Jun 22 09:39:44.373121 xxx2] [php7:notice] [pid 848] [client 192.168.0.xxx:33350] {"reqId":"OM4eno8AFpn65qmpGGBm","level":3,"time":"xxx2-06-22T16:39:44+00:00","remoteAddr":"192.168.0.xxx","user":"[name]","app":"PHP","method":"GET","url":"/nextcloud/ocs/v2.php/apps/notifications/api/v2/notifications","message":"fopen(/data/ocdata/nextcloud.log): failed to open stream: No such file or directory at /var/www/nextcloud/lib/private/Log/File.php#85","userAgent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:101.0) Gecko/20100101 Firefox/101.0","version":"20.0.14.2"}
[Wed Jun 22 09:40:35.116862 xxx2] [php7:notice] [pid 850] [client 192.168.0.xxx:33358] {"reqId":"HEX5U3QcautEOAPpo6J0","level":3,"time":"xxx2-06-22T16:40:35+00:00","remoteAddr":"192.168.0.xxx","user":"ken-pic","app":"PHP","method":"GET","url":"/nextcloud/status.php","message":"PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/lib/php/20170718/imagick.so (/usr/lib/php/20170718/imagick.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/imagick.so.so (/usr/lib/php/20170718/imagick.so.so: cannot open shared object file: No such file or directory)) at Unknown#0","userAgent":"Mozilla/5.0 (Linux) mirall/3.4.1 (build 8597) (Nextcloud, ubuntu-5.4.0-120-generic ClientArchitecture: x86_64 OsArchitecture: x86_64)","version":"20.0.14.2"}
[Wed Jun 22 09:40:35.156957 xxx2] [php7:notice] [pid 852] [client 192.168.0.xxx:33356] {"reqId":"EGfTB3jIhmURLT78WTyh","level":3,"time":"xxx2-06-22T16:40:35+00:00","remoteAddr":"192.168.0.xxx","user":"ken-lt1","app":"PHP","method":"GET","url":"/nextcloud/status.php","message":"PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/lib/php/20170718/imagick.so (/usr/lib/php/20170718/imagick.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/imagick.so.so (/usr/lib/php/20170718/imagick.so.so: cannot open shared object file: No such file or directory)) at Unknown#0","userAgent":"Mozilla/5.0 (Linux) mirall/3.4.1 (build 8597) (Nextcloud, ubuntu-5.4.0-120-generic ClientArchitecture: x86_64 OsArchitecture: x86_64)","version":"20.0.14.2"}
[Wed Jun 22 10:09:35.675827 xxx2] [mpm_prefork:notice] [pid 827] AH00169: caught SIGTERM, shutting down
PHP Warning:  PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/lib/php/20170718/imagick.so (/usr/lib/php/20170718/imagick.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/imagick.so.so (/usr/lib/php/20170718/imagick.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[Wed Jun 22 10:11:03.565734 xxx2] [mpm_prefork:notice] [pid 829] AH00163: Apache/2.4.29 (Ubuntu) configured -- resuming normal operations
[Wed Jun 22 10:11:03.565796 xxx2] [core:notice] [pid 829] AH00094: Command line: '/usr/sbin/apache2'
[Wed Jun 22 10:37:18.955573 xxx2] [mpm_prefork:notice] [pid 829] AH00169: caught SIGTERM, shutting down
PHP Warning:  PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/lib/php/20170718/imagick.so (/usr/lib/php/20170718/imagick.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/imagick.so.so (/usr/lib/php/20170718/imagick.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[Wed Jun 22 10:38:39.646187 xxx2] [mpm_prefork:notice] [pid 819] AH00163: Apache/2.4.29 (Ubuntu) configured -- resuming normal operations
[Wed Jun 22 10:38:39.646254 xxx2] [core:notice] [pid 819] AH00094: Command line: '/usr/sbin/apache2'
[Wed Jun 22 10:40:04.903709 xxx2] [autoindex:error] [pid 838] [client 192.168.0.xxx:53430] AH01276: Cannot serve directory /var/www/nextcloud/: No matching DirectoryIndex (none) found, and server-generated directory index forbidden by Options directive

PASTE HERE
Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Cannot find any log file in /var/www/. This is from nextcloud.log in the data directory. Filtered to records that have ‘error’ and today’s date.

{"reqId":"93j8DpTHKitxB3caoXzi","level":3,"time":"2022-06-22T15:33:11+00:00","remoteAddr":"192.168.0.xxx","user":"[user name]","app":"index","method":"PUT","url":"/nextcloud/apps/user_status/heartbeat","message":{"Exception":"Doctrine\\DBAL\\Exception\\UniqueConstraintViolationException","Message":"An exception occurred while executing 'INSERT INTO `oc_user_status` (`user_id`, `status`, `status_timestamp`, `is_user_defined`) VALUES(?, ?, ?, ?)' with params [\"[user name]\", \"online\", 1655911990, false]:\n\nSQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '[user name]' for key 'user_status_uid_ix'","Code":0,"Trace":[{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php","line":169,"function":"convertException","class":"Doctrine\\DBAL\\Driver\\AbstractMySQLDriver","type":"->","args":["An exception occurred while executing 'INSERT INTO `oc_user_status` (`user_id`, `status`, `status_timestamp`, `is_user_defined`) VALUES(?, ?, ?, ?)' with params [\"[user name]\", \"online\", 1655911990, false]:\n\nSQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '[user name]' for key 'user_status_uid_ix'",{"errorInfo":["23000",1062,"Duplicate entry '[user name]' for key 'user_status_uid_ix'"],"__class__":"Doctrine\\DBAL\\Driver\\PDOException"}]},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php","line":149,"function":"wrapException","class":"Doctrine\\DBAL\\DBALException","type":"::","args":[{"__class__":"Doctrine\\DBAL\\Driver\\PDOMySql\\Driver"},{"errorInfo":["23000",1062,"Duplicate entry '[user name]' for key 'user_status_uid_ix'"],"__class__":"Doctrine\\DBAL\\Driver\\PDOException"},"An exception occurred while executing 'INSERT INTO `oc_user_status` (`user_id`, `status`, `status_timestamp`, `is_user_defined`) VALUES(?, ?, ?, ?)' with params [\"[user name]\", \"online\", 1655911990, false]:\n\nSQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '[user name]' for key 'user_status_uid_ix'"]},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php","line":1071,"function":"driverExceptionDuringQuery","class":"Doctrine\\DBAL\\DBALException","type":"::","args":[{"__class__":"Doctrine\\DBAL\\Driver\\PDOMySql\\Driver"},{"errorInfo":["23000",1062,"Duplicate entry '[user name]' for key 'user_status_uid_ix'"],"__class__":"Doctrine\\DBAL\\Driver\\PDOException"},"INSERT INTO `oc_user_status` (`user_id`, `status`, `status_timestamp`, `is_user_defined`) VALUES(?, ?, ?, ?)",{"1":"[user name]","2":"online","3":1655911990,"4":false}]},{"file":"/var/www/nextcloud/lib/private/DB/Connection.php","line":222,"function":"executeUpdate","class":"Doctrine\\DBAL\\Connection","type":"->","args":["INSERT INTO `oc_user_status` (`user_id`, `status`, `status_timestamp`, `is_user_defined`) VALUES(?, ?, ?, ?)",["[user name]","online",1655911990,false],[2,2,1,5]]},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php","line":209,"function":"executeUpdate","class":"OC\\DB\\Connection","type":"->","args":["INSERT INTO `oc_user_status` (`user_id`, `status`, `status_timestamp`, `is_user_defined`) VALUES(:dcValue1, :dcValue2, :dcValue3, :dcValue4)",{"dcValue1":"[user name]","dcValue2":"online","dcValue3":1655911990,"dcValue4":false},{"dcValue1":2,"dcValue2":2,"dcValue3":1,"dcValue4":5}]},{"file":"/var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":248,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/public/AppFramework/Db/QBMapper.php","line":135,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->","args":[]},{"file":"/var/www/nextcloud/apps/user_status/lib/Listener/UserLiveStatusListener.php","line":110,"function":"insert","class":"OCP\\AppFramework\\Db\\QBMapper","type":"->","args":[{"userId":"[user name]","status":"online","statusTimestamp":1655911990,"isUserDefined":false,"messageId":null,"customIcon":null,"customMessage":null,"clearAt":null,"id":null,"__class__":"OCA\\UserStatus\\Db\\UserStatus"}]},{"file":"/var/www/nextcloud/lib/private/EventDispatcher/ServiceEventListener.php","line":76,"function":"handle","class":"OCA\\UserStatus\\Listener\\UserLiveStatusListener","type":"->","args":[{"__class__":"OCP\\User\\Events\\UserLiveStatusEvent"}]},{"file":"/var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":251,"function":"__invoke","class":"OC\\EventDispatcher\\ServiceEventListener","type":"->","args":[{"__class__":"OCP\\User\\Events\\UserLiveStatusEvent"},"OCP\\User\\Events\\UserLiveStatusEvent",{"__class__":"Symfony\\Component\\EventDispatcher\\EventDispatcher"}]},{"file":"/var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":73,"function":"callListeners","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->","args":[[{"__class__":"Closure"}],"OCP\\User\\Events\\UserLiveStatusEvent",{"__class__":"OCP\\User\\Events\\UserLiveStatusEvent"}]},{"file":"/var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php","line":86,"function":"dispatch","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->","args":[{"__class__":"OCP\\User\\Events\\UserLiveStatusEvent"},"OCP\\User\\Events\\UserLiveStatusEvent"]},{"file":"/var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php","line":98,"function":"dispatch","class":"OC\\EventDispatcher\\EventDispatcher","type":"->","args":["OCP\\User\\Events\\UserLiveStatusEvent",{"__class__":"OCP\\User\\Events\\UserLiveStatusEvent"}]},{"file":"/var/www/nextcloud/apps/user_status/lib/Controller/HeartbeatController.php","line":89,"function":"dispatchTyped","class":"OC\\EventDispatcher\\EventDispatcher","type":"->","args":[{"__class__":"OCP\\User\\Events\\UserLiveStatusEvent"}]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":169,"function":"heartbeat","class":"OCA\\UserStatus\\Controller\\HeartbeatController","type":"->","args":["online"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":100,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\UserStatus\\Controller\\HeartbeatController"},"heartbeat"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/App.php","line":152,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\UserStatus\\Controller\\HeartbeatController"},"heartbeat"]},{"file":"/var/www/nextcloud/lib/private/Route/Router.php","line":309,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\UserStatus\\Controller\\HeartbeatController","heartbeat",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"user_status.Heartbeat.heartbeat"}]},{"file":"/var/www/nextcloud/lib/base.php","line":1008,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/apps/user_status/heartbeat"]},{"file":"/var/www/nextcloud/index.php","line":37,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php","Line":55,"Previous":{"Exception":"Doctrine\\DBAL\\Driver\\PDOException","Message":"SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '[user name]' for key 'user_status_uid_ix'","Code":"23000","Trace":[{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php","line":1062,"function":"execute","class":"Doctrine\\DBAL\\Driver\\PDOStatement","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/private/DB/Connection.php","line":222,"function":"executeUpdate","class":"Doctrine\\DBAL\\Connection","type":"->","args":["INSERT INTO `oc_user_status` (`user_id`, `status`, `status_timestamp`, `is_user_defined`) VALUES(?, ?, ?, ?)",["[user name]","online",1655911990,false],[2,2,1,5]]},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php","line":209,"function":"executeUpdate","class":"OC\\DB\\Connection","type":"->","args":["INSERT INTO `oc_user_status` (`user_id`, `status`, `status_timestamp`, `is_user_defined`) VALUES(:dcValue1, :dcValue2, :dcValue3, :dcValue4)",{"dcValue1":"[user name]","dcValue2":"online","dcValue3":1655911990,"dcValue4":false},{"dcValue1":2,"dcValue2":2,"dcValue3":1,"dcValue4":5}]},{"file":"/var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":248,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/public/AppFramework/Db/QBMapper.php","line":135,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->","args":[]},{"file":"/var/www/nextcloud/apps/user_status/lib/Listener/UserLiveStatusListener.php","line":110,"function":"insert","class":"OCP\\AppFramework\\Db\\QBMapper","type":"->","args":[{"userId":"[user name]","status":"online","statusTimestamp":1655911990,"isUserDefined":false,"messageId":null,"customIcon":null,"customMessage":null,"clearAt":null,"id":null,"__class__":"OCA\\UserStatus\\Db\\UserStatus"}]},{"file":"/var/www/nextcloud/lib/private/EventDispatcher/ServiceEventListener.php","line":76,"function":"handle","class":"OCA\\UserStatus\\Listener\\UserLiveStatusListener","type":"->","args":[{"__class__":"OCP\\User\\Events\\UserLiveStatusEvent"}]},{"file":"/var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":251,"function":"__invoke","class":"OC\\EventDispatcher\\ServiceEventListener","type":"->","args":[{"__class__":"OCP\\User\\Events\\UserLiveStatusEvent"},"OCP\\User\\Events\\UserLiveStatusEvent",{"__class__":"Symfony\\Component\\EventDispatcher\\EventDispatcher"}]},{"file":"/var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":73,"function":"callListeners","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->","args":[[{"__class__":"Closure"}],"OCP\\User\\Events\\UserLiveStatusEvent",{"__class__":"OCP\\User\\Events\\UserLiveStatusEvent"}]},{"file":"/var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php","line":86,"function":"dispatch","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->","args":[{"__class__":"OCP\\User\\Events\\UserLiveStatusEvent"},"OCP\\User\\Events\\UserLiveStatusEvent"]},{"file":"/var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php","line":98,"function":"dispatch","class":"OC\\EventDispatcher\\EventDispatcher","type":"->","args":["OCP\\User\\Events\\UserLiveStatusEvent",{"__class__":"OCP\\User\\Events\\UserLiveStatusEvent"}]},{"file":"/var/www/nextcloud/apps/user_status/lib/Controller/HeartbeatController.php","line":89,"function":"dispatchTyped","class":"OC\\EventDispatcher\\EventDispatcher","type":"->","args":[{"__class__":"OCP\\User\\Events\\UserLiveStatusEvent"}]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":169,"function":"heartbeat","class":"OCA\\UserStatus\\Controller\\HeartbeatController","type":"->","args":["online"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":100,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\UserStatus\\Controller\\HeartbeatController"},"heartbeat"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/App.php","line":152,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\UserStatus\\Controller\\HeartbeatController"},"heartbeat"]},{"file":"/var/www/nextcloud/lib/private/Route/Router.php","line":309,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\UserStatus\\Controller\\HeartbeatController","heartbeat",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"user_status.Heartbeat.heartbeat"}]},{"file":"/var/www/nextcloud/lib/base.php","line":1008,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/apps/user_status/heartbeat"]},{"file":"/var/www/nextcloud/index.php","line":37,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php","Line":129,"Previous":{"Exception":"PDOException","Message":"SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '[user name]' for key 'user_status_uid_ix'","Code":"23000","Trace":[{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php","line":127,"function":"execute","class":"PDOStatement","type":"->","args":[null]},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php","line":1062,"function":"execute","class":"Doctrine\\DBAL\\Driver\\PDOStatement","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/private/DB/Connection.php","line":222,"function":"executeUpdate","class":"Doctrine\\DBAL\\Connection","type":"->","args":["INSERT INTO `oc_user_status` (`user_id`, `status`, `status_timestamp`, `is_user_defined`) VALUES(?, ?, ?, ?)",["[user name]","online",1655911990,false],[2,2,1,5]]},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php","line":209,"function":"executeUpdate","class":"OC\\DB\\Connection","type":"->","args":["INSERT INTO `oc_user_status` (`user_id`, `status`, `status_timestamp`, `is_user_defined`) VALUES(:dcValue1, :dcValue2, :dcValue3, :dcValue4)",{"dcValue1":"[user name]","dcValue2":"online","dcValue3":1655911990,"dcValue4":false},{"dcValue1":2,"dcValue2":2,"dcValue3":1,"dcValue4":5}]},{"file":"/var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":248,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->","args":[]},{"file":"/var/www/nextcloud/lib/public/AppFramework/Db/QBMapper.php","line":135,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->","args":[]},{"file":"/var/www/nextcloud/apps/user_status/lib/Listener/UserLiveStatusListener.php","line":110,"function":"insert","class":"OCP\\AppFramework\\Db\\QBMapper","type":"->","args":[{"userId":"[user name]","status":"online","statusTimestamp":1655911990,"isUserDefined":false,"messageId":null,"customIcon":null,"customMessage":null,"clearAt":null,"id":null,"__class__":"OCA\\UserStatus\\Db\\UserStatus"}]},{"file":"/var/www/nextcloud/lib/private/EventDispatcher/ServiceEventListener.php","line":76,"function":"handle","class":"OCA\\UserStatus\\Listener\\UserLiveStatusListener","type":"->","args":[{"__class__":"OCP\\User\\Events\\UserLiveStatusEvent"}]},{"file":"/var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":251,"function":"__invoke","class":"OC\\EventDispatcher\\ServiceEventListener","type":"->","args":[{"__class__":"OCP\\User\\Events\\UserLiveStatusEvent"},"OCP\\User\\Events\\UserLiveStatusEvent",{"__class__":"Symfony\\Component\\EventDispatcher\\EventDispatcher"}]},{"file":"/var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":73,"function":"callListeners","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->","args":[[{"__class__":"Closure"}],"OCP\\User\\Events\\UserLiveStatusEvent",{"__class__":"OCP\\User\\Events\\UserLiveStatusEvent"}]},{"file":"/var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php","line":86,"function":"dispatch","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->","args":[{"__class__":"OCP\\User\\Events\\UserLiveStatusEvent"},"OCP\\User\\Events\\UserLiveStatusEvent"]},{"file":"/var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php","line":98,"function":"dispatch","class":"OC\\EventDispatcher\\EventDispatcher","type":"->","args":["OCP\\User\\Events\\UserLiveStatusEvent",{"__class__":"OCP\\User\\Events\\UserLiveStatusEvent"}]},{"file":"/var/www/nextcloud/apps/user_status/lib/Controller/HeartbeatController.php","line":89,"function":"dispatchTyped","class":"OC\\EventDispatcher\\EventDispatcher","type":"->","args":[{"__class__":"OCP\\User\\Events\\UserLiveStatusEvent"}]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":169,"function":"heartbeat","class":"OCA\\UserStatus\\Controller\\HeartbeatController","type":"->","args":["online"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":100,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\UserStatus\\Controller\\HeartbeatController"},"heartbeat"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/App.php","line":152,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\UserStatus\\Controller\\HeartbeatController"},"heartbeat"]},{"file":"/var/www/nextcloud/lib/private/Route/Router.php","line":309,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\UserStatus\\Controller\\HeartbeatController","heartbeat",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"user_status.Heartbeat.heartbeat"}]},{"file":"/var/www/nextcloud/lib/base.php","line":1008,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/apps/user_status/heartbeat"]},{"file":"/var/www/nextcloud/index.php","line":37,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php","Line":127}},"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:101.0) Gecko/20100101 Firefox/101.0","version":"20.0.14.2"}

Hello,

are you using Nginx? If so, please post your nginx.conf here.

Change the default php version for the command line.

You need to update your webserver (or php-fpm) configuration as well to use the new php version.

That did it. After searching for some info I ran:
sudo a2dismod php7.2
sudo a2enmod php7.4
systemctl restart apache2

It works now. Thanks for your help.