PHP version error on OCC ciommand

Nextcloud version (eg, 18.0.2): 19.0.3
Operating system and version (eg, Ubuntu 20.04): Synology DSM
Apache or nginx version (eg, Apache 2.4.25): Apache 2.2
PHP version (eg, 7.1): 7.3

The issue you are facing:

I would like to run “occ” commands from putty but everytime I try to perform a command, I get this error:

This version of Nextcloud requires at least PHP 7.2
You are currently running 5.6.11. Please update your PHP version.

For sure, under Webstation: general settings, PHP 7.3 is configured. Also under Virtual Host PHP version 7.3 is configured.

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

Steps to replicate it:

  1. Run occ command

The output of your Nextcloud log in Admin > Logging:



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

<?php
$CONFIG = array (
  'instanceid' => 'XXX',
  'passwordsalt' => 'xxx',
  'secret' => 'xxx',
  'trusted_domains' => 
  array (
    0 => '111.222.333.444',
    1 => 'wildcard.xxx.de',
    2 => 'xxx.de/nx',
    3 => 'nx.xxx.de',
  ),
  'datadirectory' => '/volume1/web/nx/data',
  'dbtype' => 'mysql',
  'version' => '19.0.2.2',
  'overwrite.cli.url' => 'http://111.222.333.444/xx',
  'dbname' => 'nx',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'xxx',
  'dbuser' => 'xx',
  'dbpassword' => 'xxx',
  'log_type' => 'file',
  'logfile' => 'nextcloud.log',
  'loglevel' => 3,
  'logdateformat' => 'F d, Y H:i:s',
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'maintenance' => false,
  'updater.secret' => 'xxx',
  'updater.release.channel' => 'stable',
  'theme' => '', 
  'installed' => true,
);

Does anyboy know why this happens? I am not sure if this is Synology related or not.

Please post output:

which php
php --version

uname -a

Unfortunately it’s only half of the story to install a specific PHP version on a Synology NAS for the web station. PHP always exists in two different variants on a server, a web and a cli component. By installing PHP 7.3 you’ve for sure installed and activated a new PHP version, but you haven’t switched the default php one for the console command.

To use occ on the console you have to follow these hints:

https://hackabee.fr/2018/12/12/how-to-solve-php-7-bash-error-to-update-nextcloud-on-synology/

Patrick@server:/volume1/web/$ which php
/bin/php
Patrick@server:/volume1/web/$ php --version
PHP 5.6.11 (cli) (built: May 12 2020 05:25:47)
Copyright © 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright © 1998-2015 Zend Technologies
Patrick@server:/volume1/web/$ uname -a
Linux server 3.10.105 #25426 SMP Wed Jul 8 03:12:51 CST 2020 x86_64 GNU/Linux synology_braswell_216+
-sh:
Patrick@server:/volume1/web/$: No such file or directory

Intresting…
I will check the link you’ve provided, thanks!

I saw now to try with php72 the occ command.

But now, even if in the /etc/php/php.ini file 512MB is configured, I recieve the following error:
 php72 occ help
PHP Warning:  PHP Startup: Unable to load dynamic library 'mcrypt.so' (tried: /usr/local/lib/php72/modules/mcrypt.so (/usr/local/lib/php72/modules/mcrypt.so: cannot open shared object file: No such file or directory), /usr/local/lib/php72/modules/mcrypt.so.so (/usr/local/lib/php72/modules/mcrypt.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'mysql.so' (tried: /usr/local/lib/php72/modules/mysql.so (/usr/local/lib/php72/modules/mysql.so: cannot open shared object file: No such file or directory), /usr/local/lib/php72/modules/mysql.so.so (/usr/local/lib/php72/modules/mysql.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
The current PHP memory limit is below the recommended value of 512MB.
{"reqId":"rLvVhcmMUScw3ISbb4O5","level":0,"time":"September 29, 2020 23:25:23","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Deprecated event type for \\OCP\\Files::preWrite: Symfony\\Component\\EventDispatcher\\GenericEvent","userAgent":"--","version":"19.0.3.1"}
{"reqId":"rLvVhcmMUScw3ISbb4O5","level":0,"time":"September 29, 2020 23:25:23","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Deprecated event type for \\OCP\\Files::preCreate: Symfony\\Component\\EventDispatcher\\GenericEvent","userAgent":"--","version":"19.0.3.1"}
An unhandled exception has been thrown:
RuntimeException: Could not get appdata folder in /volume1/web/nx/lib/private/Files/AppData/AppData.php:94
Stack trace:
#0 /volume1/web/nx/lib/private/Files/AppData/AppData.php(110): OC\Files\AppData\AppData->getAppDataRootFolder()
#1 /volume1/web/nx/lib/private/Files/AppData/AppData.php(157): OC\Files\AppData\AppData->getAppDataFolder()
#2 /volume1/web/nx/apps/richdocuments/lib/TemplateManager.php(148): OC\Files\AppData\AppData->newFolder('templates')
#3 /volume1/web/nx/apps/richdocuments/lib/TemplateManager.php(134): OCA\Richdocuments\TemplateManager->createAppDataFolders()
#4 [internal function]: OCA\Richdocuments\TemplateManager->__construct('richdocuments', NULL, Object(OC\AllConfig), Object(OC\Files\AppData\AppData), Object(OC\URLGenerator), Object(OC\Files\Node\LazyRoot), Object(OC\L10N\LazyL10N))
#5 /volume1/web/nx/lib/private/AppFramework/Utility/SimpleContainer.php(84): ReflectionClass->newInstanceArgs(Array)
#6 /volume1/web/nx/lib/private/AppFramework/Utility/SimpleContainer.php(101): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))
#7 /volume1/web/nx/lib/private/AppFramework/Utility/SimpleContainer.php(116): OC\AppFramework\Utility\SimpleContainer->resolve('OCA\\Richdocumen...')
#8 /volume1/web/nx/lib/private/AppFramework/DependencyInjection/DIContainer.php(414): OC\AppFramework\Utility\SimpleContainer->query('OCA\\Richdocumen...')
#9 /volume1/web/nx/lib/private/AppFramework/DependencyInjection/DIContainer.php(385): OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback('OCA\\Richdocumen...')
#10 /volume1/web/nx/lib/private/AppFramework/Utility/SimpleContainer.php(71): OC\AppFramework\DependencyInjection\DIContainer->query('OCA\\Richdocumen...', true)
#11 /volume1/web/nx/lib/private/AppFramework/Utility/SimpleContainer.php(101): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))
#12 /volume1/web/nx/lib/private/AppFramework/Utility/SimpleContainer.php(116): OC\AppFramework\Utility\SimpleContainer->resolve('OCA\\Richdocumen...')
#13 /volume1/web/nx/lib/private/AppFramework/DependencyInjection/DIContainer.php(414): OC\AppFramework\Utility\SimpleContainer->query('OCA\\Richdocumen...')
#14 /volume1/web/nx/lib/private/ServerContainer.php(133): OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback('OCA\\Richdocumen...')
#15 /volume1/web/nx/lib/private/Console/Application.php(221): OC\ServerContainer->query('OCA\\Richdocumen...')
#16 /volume1/web/nx/lib/private/Console/Application.php(136): OC\Console\Application->loadCommandsFromInfoXml(Array)
#17 /volume1/web/nx/console.php(99): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /volume1/web/nx/occ(11): require_once('/volume1/web/nx...')
#19 {main}{"reqId":"rLvVhcmMUScw3ISbb4O5","level":3,"time":"September 29, 2020 23:25:23","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"PHP Startup: Unable to load dynamic library 'mysql.so' (tried: /usr/local/lib/php72/modules/mysql.so (/usr/local/lib/php72/modules/mysql.so: cannot open shared object file: No such file or directory), /usr/local/lib/php72/modules/mysql.so.so (/usr/local/lib/php72/modules/mysql.so.so: cannot open shared object file: No such file or directory)) at Unknown#0","userAgent":"--","version":"19.0.3.1"}

Again Im not sure where the issue is located, because Synology might be a bit different

As you can see essentials php modules haven’t been installed for PHP 7.2 on a Synology NAS. Due to the fact that PHP on a Synology NAS is configured differently in many ways it might be worse to check the Synology Community forum for a solution. See e.g.

It seems, that mcrypt.so is deprecated since PHP 7.1

Hello,
I get similar problem.
On a synology DSM I run 2 instances of NextCloud in parallel, with same php environment.
Both were ok with NextCloud 19 and PHP 7.2.
I updated one with latest 20.1, and had to move to PHP7.3. Since, everything working but the occ reports error on both instances

Which config file could have been modified to reintroduce request to those modules in php? I searched in different logs without success, if someone could point out the right one to check ?

note: DSM is using Maria DB for mysqli and pdo requests
Thanks

Example of occ usage : sudo -u http php73 occ db:add-missing-indices

from nextcloud.log:
{“reqId”:“tYswu8UUSUxHNxxKoXiN”,“level”:3,“time”:“2021-04-22T08:00:03+00:00”,“remoteAddr”:"",“user”:"–",“app”:“PHP”,“method”:"",“url”:"–",“message”:“PHP Startup: Unable to load dynamic library ‘mysql.so’ (tried: /usr/local/lib/php73/modules/mysql.so (/usr/local/lib/php73/modules/mysql.so: cannot open shared object file: No such file or directory), /usr/local/lib/php73/modules/mysql.so.so (/usr/local/lib/php73/modules/mysql.so.so: cannot open shared object file: No such file or directory)) at Unknown#0”,“userAgent”:"–",“version”:“21.0.1.1”}

uname -a
Linux xx 4.4.59+ #25556 SMP PREEMPT Thu Mar 4 18:03:46 CST 2021 x86_64 GNU/Linux synology_apollolake_218+

php73 --version
PHP Warning: PHP Startup: Unable to load dynamic library ‘mcrypt.so’ (tried: /usr/local/lib/php73/modules/mcrypt.so (/usr/local/lib/php73/modules/mcrypt.so: cannot open shared object file: No such file or directory), /usr/local/lib/php73/modules/mcrypt.so.so (/usr/local/lib/php73/modules/mcrypt.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘mysql.so’ (tried: /usr/local/lib/php73/modules/mysql.so (/usr/local/lib/php73/modules/mysql.so: cannot open shared object file: No such file or directory), /usr/local/lib/php73/modules/mysql.so.so (/usr/local/lib/php73/modules/mysql.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 7.3.16 (cli) (built: Sep 14 2020 18:32:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.16, Copyright (c) 1998-2018 Zend Technologies

which php /bin/php
which php73 /usr/local/bin/php73 => /var/packages/PHP7.3/target/usr/local/bin
ls -l /var/packages/PHP7.3/target/usr/local/bin
total 46852
-rwxr-xr-x 1 root root 11951864 Sep 14 2020 php73
-rwxr-xr-x 1 root root 11894152 Sep 14 2020 php73-cgi
-rwxr-xr-x 1 root root 11999032 Sep 14 2020 php73-fpm
-rwxr-xr-x 1 root root 12125440 Sep 14 2020 phpdbg73

searching for the right php.ini file… (those in /usr/local/etc/php73/php.ini or/etc/php/php.ini or in session.save.path, as « /usr/local/lib/php73/modules) they derive from the json files generated through DSM GUI : /var/packages/WebStation/etc/PHPSettings.json

Just searching to stop the logs pollution … Thanks

This behavior also occure on my installation on the DSM when using php74. no %§$ idea what do to, to fix this.