Ubuntu upgrade from 16.04 to 18.04 messed up Nextcloud installation (Fixed)

I have been running Nextcloud (15.07) installation on Ubuntu 16.04 server, but today I decided to update the OS to 18.04.

After ‘do-release-upgrade’ (where I accepted all maintainer config files) the Nextcloud server was showing screen with the following text:

* @author Joas Schilling * @author Jörn Friedrich Dreyer * @author Lukas Reschke * @author Morris Jobke * @author Robin Appelman * @author Sergio Bertolín * @author Thomas Müller * @author Vincent Petry * * @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License, version 3, * along with this program. If not, see * */ require_once __DIR__ . ‘/lib/versioncheck.php’; try { require_once __DIR__ . ‘/lib/base.php’; OC::handleRequest(); } catch(\OC\ServiceUnavailableException $ex) { \OC::$server->getLogger()->logException($ex, array(‘app’ => ‘index’)); //show the user a detailed error page OC_Template::printExceptionErrorPage($ex, 503); } catch (\OC\HintException $ex) { try { OC_Template::printErrorPage($ex->getMessage(), $ex->getHint(), 503); } catch (Exception $ex2) { try { \OC::$server->getLogger()->logException($ex, array(‘app’ => ‘index’)); \OC::$server->getLogger()->logException($ex2, array(‘app’ => ‘index’)); } catch (Throwable $e) { // no way to log it properly – but to avoid a white page of death we try harder and ignore this one here } //show the user a detailed error page OC_Template::printExceptionErrorPage($ex, 500); } } catch (\OC\User\LoginException $ex) { OC_Template::printErrorPage($ex->getMessage(), $ex->getMessage(), 403); } catch (Exception $ex) { \OC::$server->getLogger()->logException($ex, array(‘app’ => ‘index’)); //show the user a detailed error page OC_Template::printExceptionErrorPage($ex, 500); } catch (Error $ex) { try { \OC::$server->getLogger()->logException($ex, array(‘app’ => ‘index’)); } catch (Error $e) { http_response_code(500); header(‘Content-Type: text/plain; charset=utf-8’); print(“Internal Server Error\n\n”); print(“The server encountered an internal error and was unable to complete your request.\n”); print(“Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.\n”); print(“More details can be found in the webserver log.\n”); throw $ex; } OC_Template::printExceptionErrorPage($ex, 500); }

I searched for the solution and found e.g. this, but that was not my case (My apache was using php7.2), or this, but I did not have any issues with Application.php and php7.2 was not available in normal repositories. So I could not use the recommended way to (sudo apt-get install php7.2-common). Probably it would have been easy to add through some ppa, but I had already upgraded to 18.04. So I continued searching more. Here was also an issue with ‘/usr/lib/php/20151012/apcu.so’ and I had the same error in my apache error log. But the instructions there were not enough to fix my case, but now I was already on the track. There was a need to “fix” the php7.2 installation. I found this, but installing those packages were not enough for me.

I needed to add there libapache2-mod-php7.2, php7.2-intl, php7.2-xml php7.2-zip which were mentioned in the Nextcloud installation page.

So the final spell was:

sudo apt-get install php7.2 php7.2-fpm php7.2-cli php7.2-curl php7.2-gd php7.2-mysql php7.2-gd php7.2-imagick php7.2-recode php7.2-tidy php7.2-xmlrpc php7.2-mbstring zip unzip php7.2-common php7.2-opcache php7.2-json php7.2-intl php7.2-xml php7.2-zip libapache2-mod-php7.2

after that I checked

/etc/redis/redis.conf

as I had written down that the file was updated during the upgrade process.
There I didn’t noticed other changes than that the unixsockets were commented out. (Upgrade process left there the old config file as ‘redis.conf.dpkg-old’ so it was easy to check the changes.)

So uncommenting
unixsocket /var/run/redis/redis-server.sock
unixsocketperm 770

and then restarting the server. Then everything looked fine, except that the log section in Nextcloud was full of following redis errors:

Error PHP Redis::connect(): connect() failed: No such file or directory at /var/www/nextcloud/lib/private/RedisFactory.php#84

This was due to the updated /etc/redis/redis.conf. There was the unix socket file name changed from
/var/run/redis/redis.sock to /var/run/redis/redis-server.sock

However, I decided to change that in the other end, and this way hopefully keeping redis more future compatible. So editing

/var/www/nextcloud/config/config.php

and making sure that the .sock file was the same as in redis.conf file.

Then restarting the server again.

After that the log was still full of errors, but bit different than last time. Now there was

Error PHP Redis::connect(): connect() failed: Permission denied at /var/www/nextcloud/lib/private/RedisFactory.php#84

Then back to /etc/redis/redis.conf and edited
unixsockperm 700 -> 770 (which I didn’t noticed at the first time.. or second)

New restart, and there was not coming redis errors anymore.

This took me some hours and seems that there were others that were having the same error, so I thought to document it up here, if it would be helpful for somebody else.

How to upgrage Nexcloud Ubuntu 16.04 to 18.04

Summary from the above, or TLDR;

1) Upgrade Ubuntu normally (do-release-upgrade)
2) Fix php setup with command:

sudo apt-get install php7.2 php7.2-fpm php7.2-cli php7.2-curl php7.2-gd php7.2-mysql php7.2-gd php7.2-imagick php7.2-recode php7.2-tidy php7.2-xmlrpc php7.2-mbstring zip unzip php7.2-common php7.2-opcache php7.2-json php7.2-intl php7.2-xml php7.2-zip libapache2-mod-php7.2

3) Edit /etc/redis/redis.conf

Uncomment rows
unixsocket /var/run/redis/redis-server.sock
unixsocketperm 700

and change ‘unixsocketperm 700’ to ‘unixsocketperm 770’

4) edit /var/www/nextcloud/config/config.php

so that the redis.sock will point to the same file as in redis.conf