Nextcloud Unable to load dynamic library after upgrade to Ubuntu 17.10

Nextcloud version 12.0.2
Operating system and version: Ubuntu 17.10
Apache or nginx version 2.4.27
PHP version 7.1.8-1ubuntu1
Is this the first time you’ve seen this error? Yes

Can you reliably replicate it? (If so, please outline steps):

The issue you are facing:
After upgrading to Ubuntu version 17.10, I got Internal Server error when browsing “NextCloud” portal.

The output of your Nextcloud log in Admin > Logging:
NA

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 => 'localhost', 1 => ***', 2 => '****, ), 'datadirectory' => '/var/www/nextcloud/data', 'overwrite.cli.url' => 'http://localhost/nextcloud', 'dbtype' => 'mysql', 'version' => '12.0.2.0', 'dbname' => 'Nextcloud', 'dbhost' => 'localhost', 'dbport' => '', 'dbtableprefix' => 'oc_', 'mysql.utf8mb4' => true, 'dbuser' => 'oc_****', 'dbpassword' => '*********', 'installed' => true, ); ~ The output of your Apache/nginx/system log in `/var/log/____`: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/imagick.so' - /usr/lib/php/20151012/imagick.so: cannot open shared object file: No such file or directory in Unknown on line 0 [Thu Nov 02 01:34:54.746261 2017] [ssl:warn] [pid 1400] AH01909: 127.0.1.1:443:0 server certificate does NOT include an ID which matches the server name [Thu Nov 02 01:34:54.746349 2017] [mpm_prefork:notice] [pid 1400] AH00163: Apache/2.4.27 (Ubuntu) OpenSSL/1.0.2g configured -- resuming normal operations [Thu Nov 02 01:34:54.746354 2017] [core:notice] [pid 1400] AH00094: Command line: '/usr/sbin/apache2' [Thu Nov 02 01:35:11.453003 2017] [:error] [pid 6807] [client 192.168.100.10:52484] PHP Fatal error: Uncaught Doctrine\\DBAL\\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory in /var/www/nextcloud/lib/private/DB/Connection.php:61\nStack trace:\n#0 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\\DB\\Connection->connect()\n#1 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\\DBAL\\Connection->getDatabasePlatformVersion()\n#2 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\\DBAL\\Connection->detectDatabasePlatform()\n#3 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\\DBAL\\Connection->getDatabasePlatform()\n#4 /var/www/nextcloud/lib/private/DB/Connection.php(148): Doctrine\\DBAL\\Connection->setTransactionIsolation(2)\n#5 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\\DB\\Connection->__construct(Array, Object(Doctrine\\DBAL\\Driver\\PDOMySql\\Driver), Obj in /var/www/nextcloud/lib/private/DB/Connection.php on line 61 [Thu Nov 02 01:35:11.453247 2017] [:error] [pid 6807] [client 192.168.100.10:52484] PHP Fatal error: Uncaught Doctrine\\DBAL\\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory in /var/www/nextcloud/lib/private/DB/Connection.php:61\nStack trace:\n#0 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\\DB\\Connection->connect()\n#1 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\\DBAL\\Connection->getDatabasePlatformVersion()\n#2 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\\DBAL\\Connection->detectDatabasePlatform()\n#3 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\\DBAL\\Connection->getDatabasePlatform()\n#4 /var/www/nextcloud/lib/private/DB/Connection.php(148): Doctrine\\DBAL\\Connection->setTransactionIsolation(2)\n#5 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\\DB\\Connection->__construct(Array, Object(Doctrine\\DBAL\\Driver\\PDOMySql\\Driver), Obj in /var/www/nextcloud/lib/private/DB/Connection.php on line 61 Thanks for any help how to recover nextcloud.

Strange path to your libs. Looks rather like a backup path which is linked there. I guess you need to fix your PHP installation (or just link to the right path) and you should be fine again.

Thanks for quick reply.
Kindly, Is it ok if I re-install PHP without losing my data which is located in Nextcloud data directory.

Hi,
Yes it is.
To keep your data you have to make sure you don’t lose your files in your data folder and you don’t lose your database! Well and your config.php file in …/nextcloud/config/

Data folder and database are really what makes your “data”. Everything else (nginx/ apache, PHP) are only the tools to access your server and files later.

So you can re-install PHP clean and configure everything again. As long as the web server can access and use PHP again, everything should work fine again (unless there are further issues which are discovered with running PHP first).

Before you do such large upgrade, you hopefully have a backup. Especially system upgrades can be a bit tricky and I have seen some cases where it was easier to start with a fresh system. Though it often works.

I tried to re-install PHP. I also did a backup of all files and folders. However, the message I got now from Apache Error Log:
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/20151012/imagick.so’ - /usr/lib/php/201510$
[Fri Nov 03 00:06:02.145093 2017] [ssl:warn] [pid 1107] AH01909: 127.0.1.1:443:0 server certificate does NOT inclu$
[Fri Nov 03 00:06:02.145179 2017] [mpm_prefork:notice] [pid 1107] AH00163: Apache/2.4.27 (Ubuntu) OpenSSL/1.0.2g c$
[Fri Nov 03 00:06:02.145183 2017] [core:notice] [pid 1107] AH00094: Command line: ‘/usr/sbin/apache2’
[Fri Nov 03 00:06:12.491175 2017] [:error] [pid 20013] [client X.X.X.X:62662] PHP Fatal error: Uncaught Do$
[Fri Nov 03 00:06:12.491407 2017] [:error] [pid 20013] [client X.X.X.X:62662] PHP Fatal error: Uncaught Do$

what would be the issue, any suggestion please.

it looks like some php-module (for imagemagick) is missing. on my debian 9.2 i do not have it. you can try to reinstall or disable it in your php-config; a quick search also turned up this
GOOD LUCK!

Just linking to otherrelated issue