Different versions of PHP + apt autoremove = NC 17 does not work any more

Hello dear all, meet “funny” problem with Nextcloud and want to share my experience to solving it.
First of all you already know that there are some problems with NC 17.0.x and PHP 7.4 → This version of Nextcloud is not compatible with > PHP 7.3. But newer PHP version is already delivered to the Repositories and e.g. Ubuntu 18.04 will install it automatically and you need to use php 7.3 for NC.

  1. Problem I meet is that PHP 7.4 is not supported by current NC version and I easy solve it via command:
  1. After some time there were few packages that “were automatically installed and are no longer required” So I use autoremove and did the job. To be honest I never checked what exactly was removed till NC dies :slight_smile::
sudo apt autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  php7.3-bz2 php7.3-curl php7.3-gd php7.3-intl php7.3-mysql php7.3-xml php7.3-zip
0 upgraded, 0 newly installed, 7 to remove and 33 not upgraded.
After this operation, 1187 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 76815 files and directories currently installed.)
Removing php7.3-bz2 (7.3.13-1+ubuntu18.04.1+deb.sury.org+1) ...
Removing php7.3-curl (7.3.13-1+ubuntu18.04.1+deb.sury.org+1) ...
Removing php7.3-gd (7.3.13-1+ubuntu18.04.1+deb.sury.org+1) ...
Removing php7.3-intl (7.3.13-1+ubuntu18.04.1+deb.sury.org+1) ...
Removing php7.3-mysql (7.3.13-1+ubuntu18.04.1+deb.sury.org+1) ...
Removing php7.3-xml (7.3.13-1+ubuntu18.04.1+deb.sury.org+1) ...
Removing php7.3-zip (7.3.13-1+ubuntu18.04.1+deb.sury.org+1) ...
Processing triggers for php7.3-fpm (7.3.13-1+ubuntu18.04.1+deb.sury.org+1) ...
NOTICE: Not enabling PHP 7.3 FPM by default.
NOTICE: To enable PHP 7.3 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php7.3-fpm
NOTICE: You are seeing this message because you have apache2 package installed.
Processing triggers for libapache2-mod-php7.3 (7.3.13-1+ubuntu18.04.1+deb.sury.org+1) ...

As you can see some needed PHP 7.3. were removed because php 7.4 versions of them are installed, but I did again not notice it when run autoremove command.

  1. This drives us to the “Internal Server Error” in the browser and by running occ command to DB Access failure:
sudo -u www-data php occ
An unhandled exception has been thrown:
Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occurred in driver: could not find driver in /var/www/nextcloud/lib/private/DB/Connection.php:64
Stack trace:
#0 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(420): OC\DB\Connection->connect()
#1 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(380): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#2 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(324): Doctrine\DBAL\Connection->detectDatabasePlatform()
#3 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(683): Doctrine\DBAL\Connection->getDatabasePlatform()
#4 /var/www/nextcloud/lib/private/DB/Connection.php(151): Doctrine\DBAL\Connection->setTransactionIsolation(2)
#5 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(195): OC\DB\Connection->__construct(Array, Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Object(Doctrine\DBAL\Configuration), Object(Doctrine\Common\EventManager))
#6 /var/www/nextcloud/lib/private/DB/ConnectionFactory.php(156): Doctrine\DBAL\DriverManager::getConnection(Array, Object(Doctrine\DBAL\Configuration), Object(Doctrine\Common\EventManager))
#7 /var/www/nextcloud/lib/private/Server.php(635): OC\DB\ConnectionFactory->getConnection('mysql', Array)
#8 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
#9 /var/www/nextcloud/lib/private/ServerContainer.php(120): Pimple\Container->offsetGet('OCP\\IDBConnecti...')
#10 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(161): OC\ServerContainer->query('OCP\\IDBConnecti...')
#11 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#12 /var/www/nextcloud/lib/private/ServerContainer.php(120): Pimple\Container->offsetGet('DatabaseConnect...')
#13 /var/www/nextcloud/lib/private/Server.php(1554): OC\ServerContainer->query('DatabaseConnect...')
#14 /var/www/nextcloud/lib/private/Server.php(362): OC\Server->getDatabaseConnection()
#15 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
#16 /var/www/nextcloud/lib/private/ServerContainer.php(120): Pimple\Container->offsetGet('OC\\Authenticati...')
#17 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(69): OC\ServerContainer->query('OC\\Authenticati...', true)
#18 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(99): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))
#19 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(114): OC\AppFramework\Utility\SimpleContainer->resolve('OC\\Authenticati...')
#20 /var/www/nextcloud/lib/private/ServerContainer.php(145): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...', true)
#21 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(69): OC\ServerContainer->query('OC\\Authenticati...', true)
#22 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(99): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))
#23 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(114): OC\AppFramework\Utility\SimpleContainer->resolve('OC\\Authenticati...')
#24 /var/www/nextcloud/lib/private/ServerContainer.php(145): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...', true)
#25 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(161): OC\ServerContainer->query('OC\\Authenticati...')
#26 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#27 /var/www/nextcloud/lib/private/ServerContainer.php(120): Pimple\Container->offsetGet('OC\\Authenticati...')
#28 /var/www/nextcloud/lib/private/Server.php(374): OC\ServerContainer->query('OC\\Authenticati...')
#29 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
#30 /var/www/nextcloud/lib/private/ServerContainer.php(120): Pimple\Container->offsetGet('OC\\User\\Session')
#31 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(161): OC\ServerContainer->query('OC\\User\\Session')
#32 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#33 /var/www/nextcloud/lib/private/ServerContainer.php(120): Pimple\Container->offsetGet('UserSession')
#34 /var/www/nextcloud/lib/private/Server.php(1430): OC\ServerContainer->query('UserSession')
#35 /var/www/nextcloud/lib/private/Server.php(688): OC\Server->getUserSession()
#36 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
#37 /var/www/nextcloud/lib/private/ServerContainer.php(120): Pimple\Container->offsetGet('OC\\App\\AppManag...')
#38 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(161): OC\ServerContainer->query('OC\\App\\AppManag...')
#39 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#40 /var/www/nextcloud/lib/private/ServerContainer.php(120): Pimple\Container->offsetGet('AppManager')
#41 /var/www/nextcloud/lib/private/Server.php(1725): OC\ServerContainer->query('AppManager')
#42 /var/www/nextcloud/lib/private/legacy/app.php(346): OC\Server->getAppManager()
#43 /var/www/nextcloud/lib/private/legacy/app.php(114): OC_App::getEnabledApps()
#44 /var/www/nextcloud/lib/base.php(640): OC_App::loadApps(Array)
#45 /var/www/nextcloud/lib/base.php(1078): OC::init()
#46 /var/www/nextcloud/console.php(46): require_once('/var/www/nextcl...')
#47 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')
#48 {main}
  1. What to do? Check installed PHP version and modules:
$ php -i | grep php.ini
Configuration File (php.ini) Path => /etc/php/7.3/cli
Loaded Configuration File => /etc/php/7.3/cli/php.ini

$ php -m               
[PHP Modules]
apcu
calendar
Core
ctype
date
exif
fileinfo
filter
ftp
gettext
hash
iconv
igbinary
imagick
json
ldap
libxml
mbstring
openssl
pcntl
pcre
PDO
Phar
posix
readline
redis
Reflection
session
shmop
snmp
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
Zend OPcache
zlib

[Zend Modules]
Zend OPcache
  1. Check official documentation about needed modules and see that my list is inconsistent.
  2. Install needed modules:
$ sudo apt install php7.3-bz2 php7.3-curl php7.3-gd php7.3-intl php7.3-xml php7.3-zip php7.3-mysql 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  php7.3-bz2 php7.3-curl php7.3-gd php7.3-intl php7.3-xml php7.3-zip hp7.3-mysql
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 271 kB of archives.
After this operation, 918 kB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main armhf php7.3-bz2 armhf 7.3.14-1+ubuntu18.04.1+deb.sury.org+1 [8756 B]
Get:2 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main armhf php7.3-curl armhf 7.3.14-1+ubuntu18.04.1+deb.sury.org+1 [26.6 kB]
Get:3 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main armhf php7.3-gd armhf 7.3.14-1+ubuntu18.04.1+deb.sury.org+1 [23.0 kB]
Get:4 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main armhf php7.3-intl armhf 7.3.14-1+ubuntu18.04.1+deb.sury.org+1 [107 kB]
Get:5 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main armhf php7.3-xml armhf 7.3.14-1+ubuntu18.04.1+deb.sury.org+1 [88.1 kB]
Get:6 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main armhf php7.3-zip armhf 7.3.14-1+ubuntu18.04.1+deb.sury.org+1 [17.8 kB]
Get:7 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main armhf php7.3-mysql armhf 7.3.14-1+ubuntu18.04.1+deb.sury.org+1 [97.6 kB]
Fetched 311 kB in 1s (448 kB/s)       
Selecting previously unselected package php7.3-bz2.
(Reading database ... 76750 files and directories currently installed.)
Preparing to unpack .../0-php7.3-bz2_7.3.14-1+ubuntu18.04.1+deb.sury.org+1_armhf.deb ...
Unpacking php7.3-bz2 (7.3.14-1+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package php7.3-curl.
Preparing to unpack .../1-php7.3-curl_7.3.14-1+ubuntu18.04.1+deb.sury.org+1_armhf.deb ...
Unpacking php7.3-curl (7.3.14-1+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package php7.3-gd.
Preparing to unpack .../2-php7.3-gd_7.3.14-1+ubuntu18.04.1+deb.sury.org+1_armhf.deb ...
Unpacking php7.3-gd (7.3.14-1+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package php7.3-intl.
Preparing to unpack .../3-php7.3-intl_7.3.14-1+ubuntu18.04.1+deb.sury.org+1_armhf.deb ...
Unpacking php7.3-intl (7.3.14-1+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package php7.3-xml.
Preparing to unpack .../4-php7.3-xml_7.3.14-1+ubuntu18.04.1+deb.sury.org+1_armhf.deb ...
Unpacking php7.3-xml (7.3.14-1+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package php7.3-zip.
Preparing to unpack .../5-php7.3-zip_7.3.14-1+ubuntu18.04.1+deb.sury.org+1_armhf.deb ...
Unpacking php7.3-zip (7.3.14-1+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package php7.3-mysql.
(Reading database ... 76737 files and directories currently installed.)
Preparing to unpack .../php7.3-mysql_7.3.14-1+ubuntu18.04.1+deb.sury.org+1_armhf.deb ...
Unpacking php7.3-mysql (7.3.14-1+ubuntu18.04.1+deb.sury.org+1) ...
Setting up php7.3-mysql (7.3.14-1+ubuntu18.04.1+deb.sury.org+1) ...
Processing triggers for libapache2-mod-php7.3 (7.3.14-1+ubuntu18.04.1+deb.sury.org+1) ...
Processing triggers for php7.3-fpm (7.3.14-1+ubuntu18.04.1+deb.sury.org+1) ...
NOTICE: Not enabling PHP 7.3 FPM by default.
NOTICE: To enable PHP 7.3 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php7.3-fpm
NOTICE: You are seeing this message because you have apache2 package installed.
Processing triggers for php7.3-cli (7.3.14-1+ubuntu18.04.1+deb.sury.org+1) ...
Setting up php7.3-zip (7.3.14-1+ubuntu18.04.1+deb.sury.org+1) ...
Setting up php7.3-bz2 (7.3.14-1+ubuntu18.04.1+deb.sury.org+1) ...
Setting up php7.3-curl (7.3.14-1+ubuntu18.04.1+deb.sury.org+1) ...
Setting up php7.3-xml (7.3.14-1+ubuntu18.04.1+deb.sury.org+1) ...
Setting up php7.3-gd (7.3.14-1+ubuntu18.04.1+deb.sury.org+1) ...
Setting up php7.3-intl (7.3.14-1+ubuntu18.04.1+deb.sury.org+1) ...
Processing triggers for php7.3-fpm (7.3.14-1+ubuntu18.04.1+deb.sury.org+1) ...
NOTICE: Not enabling PHP 7.3 FPM by default.
NOTICE: To enable PHP 7.3 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php7.3-fpm
NOTICE: You are seeing this message because you have apache2 package installed.
Processing triggers for libapache2-mod-php7.3 (7.3.14-1+ubuntu18.04.1+deb.sury.org+1) ...
Processing triggers for php7.3-cli (7.3.14-1+ubuntu18.04.1+deb.sury.org+1) ...
  1. And restart the server and enjoy:
    $ sudo /bin/systemctl restart php7.3-fpm && sudo /bin/systemctl restart apache2 && sudo /bin/systemctl restart redis-server

Now I will check what kind of packages will be autoremoved before to do this.

Glad you fixed your installation.

Running Ubuntu 18.04 myself and without adding other repositories it will install php 7.2.24.
You added repos from deb.sury.org, right?

See https://repology.org/project/php/badges as well.

1 Like