Nextcloud fails to start after upgrading Ubuntu 20 to Ubuntu 22

Support intro

I’ve been using Nextcloud mainly as a remote calendar server, to which I connected various Thunderbird clients on Windows.

I just upgraded the operating system of my Nextcloud host (called late6500b) from Ubuntu 20 to Ubuntu 22 with the do-release-upgrade command. After the upgrade the Nextcloud GUI did not show the expected output anymore and Thunderbird could not connect to the remote Nextcloud calendar anymore.

Nextcloud version: 25.0.13.2
Operating system and version: Ubuntu 22.04
Apache version : 2.4.52
PHP version: 8.1.2-1ubuntu2.18 (cli)

The Nexcloud web administration page fails with the following (code-only) output:

<?php
/**
 * @copyright Copyright (c) 2016, ownCloud, Inc.
...
 *
 */
require_once __DIR__ . '/lib/versioncheck.php';

try {
	require_once __DIR__ . '/lib/base.php';

	OC::handleRequest();
} catch (\OC\ServiceUnavailableException $ex) {
	\OC::$server->getLogger()->logException($ex, ['app' => 'index']);

	//show the user a detailed error page
	OC_Template::printExceptionErrorPage($ex, 503);
} catch (\OCP\HintException $ex) {
	try {
		OC_Template::printErrorPage($ex->getMessage(), $ex->getHint(), 503);
	} catch (Exception $ex2) {
		try {
			\OC::$server->getLogger()->logException($ex, ['app' => 'index']);
			\OC::$server->getLogger()->logException($ex2, ['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) {
	$request = \OC::$server->getRequest();
	/**
	 * Routes with the @CORS annotation and other API endpoints should
	 * not return a webpage, so we only print the error page when html is accepted,
	 * otherwise we reply with a JSON array like the SecurityMiddleware would do.
	 */
	if (stripos($request->getHeader('Accept'), 'html') === false) {
		http_response_code(401);
		header('Content-Type: application/json; charset=utf-8');
		echo json_encode(['message' => $ex->getMessage()]);
		exit();
	}
	OC_Template::printErrorPage($ex->getMessage(), $ex->getMessage(), 401);
} catch (Exception $ex) {
	\OC::$server->getLogger()->logException($ex, ['app' => 'index']);

	//show the user a detailed error page
	OC_Template::printExceptionErrorPage($ex, 500);
} catch (Error $ex) {
	try {
		\OC::$server->getLogger()->logException($ex, ['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);
}

The Nextcloud configuration in /var/www/vhost0/config/config.php looks like this:

<?php
$CONFIG = array (
  'instanceid' => 'ociyq9uyd6gp',
  'passwordsalt' => 'j****************************k',
  'secret' => 'gweMD95***************************************j0',
  'trusted_domains' =>
  array (
    0 => 'late6500b',
  ),
  'datadirectory' => '/var/www/vhost0/data',
  'dbtype' => 'mysql',
  'version' => '25.0.13.2',
  'overwrite.cli.url' => 'http://late6500b',
  'dbname' => 'nextcloud0',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'ncuser0',
  'dbpassword' => 'n**************0',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'htaccess.RewriteBase' => '/',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
);

The output of the Apache log in /var/log/apache2/access.log looks like this:

192.168.2.65 - - [25/Jun/2024:16:34:21 +0200] "GET / HTTP/1.1" 304 447 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0"
192.168.2.65 - - [25/Jun/2024:16:35:07 +0200] "PROPFIND /remote.php/dav/calendars/myncadmin/personal/ HTTP/1.1" 405 755 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:115.0) Gecko/20100101 Thunderbird/1
15.12.1"

All of these entries come from my Windows machine with one of the Thunderbird clients, the first one as I was trying to access the Nextcloud web GUI and the second one as I was trying to access the calendar from Thunderbird.

All entries in /var/www/vhost0/data/nextcloud.log have timestamps that precede the upgrade.

I can access the MySQL database of the Nextcloud server remotely.

Any idea where to start debugging this?

Thank you.

Simple answer: Your webserver is not correctly working. It does not process php files, instead it delivers code as plain text.

Please search the forum or the web.

For ubuntu you can check the official docs as well. Looks like you are missing php packages.

1 Like

Here’s what I did:

root@late6500b:~# a2enmod php8.1
root@late6500b:~# systemctl restart apache2
root@late6500b:~# a2dismod php7.4
removing dangling symlink /etc/apache2/mods-enabled/php7.4.load
removing dangling symlink /etc/apache2/mods-enabled/php7.4.conf

root@late6500b:/var/www# chown -R www-data:www-data /var/www/vhost0/

Following this I regained access to the Nextcloud GUI, including to its calendar application and Thunderbird regained access to the remote calendar.

2 Likes

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.