JRA's picture

Hi, how would I go about updating my version of PHP to 8.x?  My web host uses v8 and I don't want to build a website locally that I can't then upload to my host.

 

Thanks,

J

Forum: 
Jeremy Davis's picture

As a general rule we recommend that where possible, you prefer the default libraries provided by Debian. One reason behind that is because then you will get automated security updates from the Debian Security team (which make the minimal changes whilst fixing security issues).

However, PHP version is perhaps one of the most asked for things and we get it. PHP is under relatively rapid development and the newer releases often support new features and stricter standards (both of which usually mean better performance and enforce/encourage better code standards).

Another reason why we don't recommend updating to newer versions of packages (other than from an official source, such as Debian themselves) is because you need to add third party repositories, which may or may not be reputable and trustable. In the case of PHP, we have a very reliable source! Ondřej Surý is a Debian/Ubuntu developer and maintainer, who is a member of the PHP packaging teams of both distros. So he is intimately involved in the development and maintenance of the official Debian and Ubuntu PHP packages. Thankfully, he provides a third party apt repo that is specifically aimed at Debian (so works flawlessly with TurnKey).

I do have dreams of providing a TurnKey tool that can allow you to easily change PHP versions. Unfortunately, that remains a dream for now. I did start work on it ages ago, but it stalled and other priorities have intervened... In the meantime though, it's still possible - just not very "turnkey"!

FYI, you can find lots of info how to update PHP on Debian all over the net (try googling something like "debian install php 8 sury.org"). Any/most of those should work (so long as you keep in mind the relevant Debian version; TKL v16.x = Debian 10/Buster; TKL v17.x = Debian Bullseye/11). The general process is even covered in an old post by me. However, the README.txt I refer to (in that post) has since been improved. So I'd just recommend using that now.


In an effort to make this post a little more generic (so it should work with both v16.x & v17.x appliances - perhaps even newer releases, once we get there) I'll try to write this in a somewhat generic way. Ideally I think that this should be a doc page, so I'll probably transfer this to a doc page once we've confirmed that it works reliably.

First, here is an overview of the process:

  1. Set PHP version to install and collect current PHP version & packages.
  2. Set up sury.org PHP.
  3. Install relevant new packages.
  4. Reapply php.ini tweaks, restart Apache and win!

I'll go through each step in more detail below, but please keep in mind that to work, these commands all need to be run within a single terminal session (some of the earlier commands set variables that are used in later steps).


Set PHP version to install and collect current PHP version & packages

To ensure that all the same PHP modules are (re)installed for the new version of PHP, set the new PHP version to install and collect the current PHP version and currently installed packages (and generate a list of new packages to install):

PHPV_NEW=8.0 # change this to the PHP version to be installed
PHPV_OLD=$(apt-cache policy php | sed -n "\|Candidate:| s|.*Candidate: [0-9]\+:\([0-9]\+\.[0-9]\+\).*$|\1|p")
PHP_OLD_PKGS=$(apt-cache policy *php${PHPV_OLD}* | grep -v "Installed: (none)" | grep "Installed:" -B1 | sed -n "\|php${PHPV_OLD}| s|^\([a-z0-9\.-]*\).*$|\1|p")
PHP_NEW_PKGS=$(echo "$PHP_OLD_PKGS" | sed "s|$PHPV_OLD|$PHPV_NEW|")

Set up sury.org PHP

As I noted above, the deb.sury.org README.txt has been improved in more recent times and I now suggest just using that for the initial setup:

curl -sSL https://packages.sury.org/php/README.txt | bash -x

Install relevant new packages

Then install the new version of PHP and the relevant libraries and modules, including Apache mod_php:

First double check the modules that will be installed:

echo "$PHP_NEW_PKGS"

That should return a list that looks vaguely like this (the specific packages may be different as different appliances have different modules pre-installed):

php8.0-mbstring
php8.0-readline
php8.0-gd
php8.0-opcache
libapache2-mod-php8.0
php8.0-cli
php8.0-dev
php8.0-mysql
php8.0-gmp
php8.0-json
php8.0-xml
php8.0-zip
php8.0-common

Install these new packages like this:

apt install -y $PHP_NEW_PKGS

If there are additional modules that you want to install, install like this:

apt install -y php${PHPV_NEW}-module_name

Where 'module_name" is the actual PHP module name, e.g. 'mbstring' or 'curl' etc. In future shell sessions, you won't have the variable PHPV_NEW set, so just substitute the PHP version number. I.e. to install the PHP curl module for PHP 8.0:

apt install -y php8.0-curl

Reapply php.ini tweaks, restart Apache and win!

The new version of PHP comes with it's own copy of the relevant php.ini file(s). You will likely want to re-apply any tweaks that you had previously applied to the relevant php.ini file(s). The new php.ini files are found at /etc/php/${PHPV_NEW}/apache2/php.ini (or /etc/php/${PHPV_NEW}/php-fpm/php.ini if used with PHP-FPM e.g. if using Nginx instead of Apache) and /etc/php/${PHPV_NEW}/cli/php.ini. Unfortunately, there isn't currently an automated or easy way to check for modifications that have been made previously. But hopefully you can work that out?!

[update] You'll also want to ensure that when you use php from the commandline, you will (almost certainly) want to use the same version of PHP as you've just installed. This may have been auto-configured by previous steps, but just in case, I suggest explicitly setting it. To ensure that you're using the right version from the CLI, run 'update-alternatives', like this:

update-alternatives --set php /usr/bin/php${PHPV_NEW}

Running the wrong version of PHP from CLI might cause issues with cron jobs (otherwise, they will likely run under the old version).

Once you've made your desired tweaks to the relevant php.ini file(s), then restarting Apache should be the only remaining step. Like this:

systemctl restart apache2

(Or if using PHP-FPM: 'systemctl restart php-fpm')

I hope that all "just works". Please let me know how you go with it.

Francisco's picture

Hi, I was going through this and was just going to say thanks and adding the following note: when running those commands, package php8.0-json isn't needed. It gives the following warning: " php8.0-json is a virtual package provided by (...) - other packages already on the list. BUT: the system continued picking with the 7.3, even with "php --version" showing PHP 8.0.22 (cli). I tried to activate this version, and suddenly I have 8.1 installed and now I'm not able to access my nextcloud. Just noticed too that my snapshot failed "error:job errors". I'm panicking. :/  Going through the browser says: 
Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.
Doing "sudo update-alternatives --list php" shows 7.3 8.0 and 8.1 and if I try to purge 8.1 it says that it's not installed. I know that I've a PHP issue, but I don't know how to tackle it, and I'm really afraid of losing all my data. Can someone please help? 
Jeremy Davis's picture

Your data shouldn't be at risk, but it's always a good idea to have current backups, especially before you do anything like this. Ideally, you should have made sure that you have a current, working backup before you started! TKLBAM is a good option, although simply creating a copy of your web root and a dump of your DB are a decent "poor man's backup". Although if you care about your data, I urge you to set up an automated backup regime, ideally to a remote location.

Anyway, to create a "poor man's local backup" of Nextcloud (and data) something like this should do the trick:

cp -R /var/www /var/www.bak
# assuming DB name is 'nextcloud'
mysqldump nextcloud > /var/www.bak/nextcloud-dump.sql

When you are done and want to get rid of the local backup, just delete it like this:

rm -r /var/www.bak

Now to fix your server. Assuming that you are trying to install PHP 8.1, please try this:

apt install -y php8.1 libapache2-mod-php8.1
systemctl restart apache2

Also, to ensure that you are using PHP 8.1 when using PHP via the CLI, run this:

update-alternatives --set php /usr/bin/php8.1

I'll update my previous post(s) to include that update alternatives command. I didn't think of that before and It might cause issues for some cron jobs otherwise!

Francisco's picture

Hi Jeremy,  I really appreciate your help and quick reply. You're absolutely right about my lack of backup strategy, more than fair reason to which I've already called myself multiple ugly names due to it. Direct updates in the production environment without any backup: can't be more stupid than that. And I've there not only all my data, but as well my girlfriend's data - I'm really panicking (and hopefully she hasn't noticed it yet). I'll fix it with TKLBAM immediately after being capable of getting access back again to the data - and I'm praying for that possibility. Unfortunately, the solution above didn't work. Meanwhile, I've eliminated php8.1 references, having only 7.3 (the one that was working) and 8.0 (the one that I was installing to be able to move to NC24). Running php --version it gives PHP 8.0.22 (cli) which should be ok. If relevant, I have a TKL NC container (in Proxmox with an AMD64 machine) with the last NC23 update possible with php7.3 (NC23.XX). When I now try to access NC through the browser I get the following page: 
<?php
/**
 * @copyright Copyright (c) 2016, ownCloud, Inc.
 *
 * @author Christoph Wurst <christoph@winzerhof-wurst.at>
 * @author Joas Schilling <coding@schilljs.com>
 * @author Jörn Friedrich Dreyer <jfd@butonic.de>
 * @author Lukas Reschke <lukas@statuscode.ch>
 * @author Morris Jobke <hey@morrisjobke.de>
 * @author Robin Appelman <robin@icewind.nl>
 * @author Roeland Jago Douma <roeland@famdouma.nl>
 * @author Sergio Bertolín <sbertolin@solidgear.es>
 * @author Thomas Müller <thomas.mueller@tmit.eu>
 * @author Vincent Petry <vincent@nextcloud.com>
 *
 * @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 <http://www.gnu.org/licenses/>
 *
 */
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);
}
In /var/log/apache2/error.log I've the following:
[Sat Sep 03 14:27:58.728828 2022] [mpm_worker:notice] [pid 7009:tid 140538516767872] AH00292: Apache/2.4.38 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Sat Sep 03 14:27:58.728846 2022] [core:notice] [pid 7009:tid 140538516767872] AH00094: Command line: '/usr/sbin/apache2'
[Sat Sep 03 14:30:05.831401 2022] [mpm_worker:notice] [pid 7009:tid 140538516767872] AH00295: caught SIGTERM, shutting down
[Sat Sep 03 14:30:11.270982 2022] [ssl:warn] [pid 292:tid 140107811546240] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sat Sep 03 14:30:11.271224 2022] [ssl:warn] [pid 292:tid 140107811546240] AH01909: localhost:12322:0 server certificate does NOT include an ID which matches the server name
[Sat Sep 03 14:30:11.275275 2022] [ssl:warn] [pid 299:tid 140107811546240] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sat Sep 03 14:30:11.275475 2022] [ssl:warn] [pid 299:tid 140107811546240] AH01909: localhost:12322:0 server certificate does NOT include an ID which matches the server name
In /var/www/nextcloud/data/nextcloud.log I've the following:
[Sat Sep 03 14:27:58.695423 2022] [mpm_worker:notice] [pid 6940:tid 140136890475648] AH00295: caught SIGTERM, shutting down
[Sat Sep 03 14:27:58.723751 2022] [ssl:warn] [pid 7008:tid 140538516767872] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sat Sep 03 14:27:58.723992 2022] [ssl:warn] [pid 7008:tid 140538516767872] AH01909: localhost:12322:0 server certificate does NOT include an ID which matches the server name
[Sat Sep 03 14:27:58.727970 2022] [ssl:warn] [pid 7009:tid 140538516767872] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sat Sep 03 14:27:58.728222 2022] [ssl:warn] [pid 7009:tid 140538516767872] AH01909: localhost:12322:0 server certificate does NOT include an ID which matches the server name
[Sat Sep 03 14:27:58.728828 2022] [mpm_worker:notice] [pid 7009:tid 140538516767872] AH00292: Apache/2.4.38 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Sat Sep 03 14:27:58.728846 2022] [core:notice] [pid 7009:tid 140538516767872] AH00094: Command line: '/usr/sbin/apache2'
[Sat Sep 03 14:30:05.831401 2022] [mpm_worker:notice] [pid 7009:tid 140538516767872] AH00295: caught SIGTERM, shutting down
[Sat Sep 03 14:30:11.270982 2022] [ssl:warn] [pid 292:tid 140107811546240] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sat Sep 03 14:30:11.271224 2022] [ssl:warn] [pid 292:tid 140107811546240] AH01909: localhost:12322:0 server certificate does NOT include an ID which matches the server name
  GNU nano 3.2                                                   nextcloud.log                                                              
{"reqId":"7W48fZ8iiJ0zjBr1gKLY","level":3,"time":"2021-04-15T23:37:02+00:00","remoteAddr":"","user":"admin","app":"no app in context","method":"","url":"--","message":{"Exception":"OCP\\AppFramework\\QueryException","Message":"Could not resolve trashManager! Class trashManager does not exist","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":126,"function":"resolve","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["trashManager"]},{"file":"/var/www/nextcloud/lib/private/ServerContainer.php","line":162,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["trashManager",true]},{"file":"/var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php","line":434,"function":"query","class":"OC\\ServerContainer","type":"->","args":["trashManager",true]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":56,"function":"query","class":"OC\\AppFramework\\DependencyInjection\\DIContainer","type":"->","args":["trashManager"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Bootstrap/FunctionInjector.php","line":58,"function":"get","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->","args":["trashManager"]},{"function":"OC\\AppFramework\\Bootstrap\\{closure}","class":"OC\\AppFramework\\Bootstrap\\FunctionInjector","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Bootstrap/FunctionInjector.php","line":68,"function":"array_map","args":[{"__class__":"Closure"},[{"name":"serverContainer","__class__":"ReflectionParameter"},{"name":"logger","__class__":"ReflectionParameter"},{"name":"appManager","__class__":"ReflectionParameter"},"*** sensitive parameter replaced ***"]]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Bootstrap/BootContext.php","line":52,"function":"injectFn","class":"OC\\AppFramework\\Bootstrap\\FunctionInjector","type":"->","args":[[{"__class__":"OCA\\Files_Trashbin\\AppInfo\\Application"},"registerTrashBackends"]]},{"file":"/var/www/nextcloud/apps/files_trashbin/lib/AppInfo/Application.php","line":57,"function":"injectFn","class":"OC\\AppFramework\\Bootstrap\\BootContext","type":"->","args":[[{"__class__":"OCA\\Files_Trashbin\\AppInfo\\Application"},"registerTrashBackends"]]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php","line":176,"function":"boot","class":"OCA\\Files_Trashbin\\AppInfo\\Application","type":"->","args":[{"__class__":"OC\\AppFramework\\Bootstrap\\BootContext"}]},{"file":"/var/www/nextcloud/lib/private/legacy/OC_App.php","line":197,"function":"bootApp","class":"OC\\AppFramework\\Bootstrap\\Coordinator","type":"->","args":["files_trashbin"]},{"file":"/var/www/nextcloud/lib/private/legacy/OC_App.php","line":137,"function":"loadApp","class":"OC_App","type":"::","args":["files_trashbin"]},{"file":"/var/www/nextcloud/apps/dav/lib/AppInfo/Application.php","line":124,"function":"loadApps","class":"OC_App","type":"::","args":[["dav"]]},{"file":"/var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php","line":176,"function":"boot","class":"OCA\\DAV\\AppInfo\\Application","type":"->","args":[{"__class__":"OC\\AppFramework\\Bootstrap\\BootContext"}]},{"file":"/var/www/nextcloud/lib/private/legacy/OC_App.php","line":197,"function":"bootApp","class":"OC\\AppFramework\\Bootstrap\\Coordinator","type":"->","args":["dav"]},{"file":"/var/www/nextcloud/lib/private/legacy/OC_App.php","line":137,"function":"loadApp","class":"OC_App","type":"::","args":["dav"]},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Util.php","line":203,"function":"loadApps","class":"OC_App","type":"::","args":[["filesystem"]]},{"file":"/var/www/nextcloud/lib/private/User/Session.php","line":554,"function":"setupFS","class":"OC_Util","type":"::","args":["*** sensitive parameter replaced ***"]},{"file":"/var/www/nextcloud/lib/private/User/Session.php","line":415,"function":"prepareUserLogin","class":"OC\\User\\Session","type":"->","args":[true,"*** sensitive parameter replaced ***"]},{"file":"/var/www/nextcloud/lib/private/User/Session.php","line":624,"function":"completeLogin","class":"OC\\User\\Session","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/User/Session.php","line":367,"function":"loginWithPassword","class":"OC\\User\\Session","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/Setup.php","line":440,"function":"login","class":"OC\\User\\Session","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/core/Command/Maintenance/Install.php","line":108,"function":"install","class":"OC\\Setup","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/3rdparty/symfony/console/Command/Command.php","line":255,"function":"execute","class":"OC\\Core\\Command\\Maintenance\\Install","type":"->","args":[{"__class__":"Symfony\\Component\\Console\\Input\\ArgvInput"},{"__class__":"Symfony\\Component\\Console\\Output\\ConsoleOutput"}]},{"file":"/var/www/nextcloud/3rdparty/symfony/console/Application.php","line":1009,"function":"run","class":"Symfony\\Component\\Console\\Command\\Command","type":"->","args":[{"__class__":"Symfony\\Component\\Console\\Input\\ArgvInput"},{"__class__":"Symfony\\Component\\Console\\Output\\ConsoleOutput"}]},{"file":"/var/www/nextcloud/3rdparty/symfony/console/Application.php","line":273,"function":"doRunCommand","class":"Symfony\"nextcloud.log" 2L, 14241C
Does it rings some bell about the issue and how to fix it? Is there any more info that I could provide that could help understanding what's happening? Thank you so much.
Jeremy Davis's picture

As I noted, your data should be ok. Most of it is in the database and as PHP isn't running properly, the risk of your data getting corrupted is fairly low IMO. I do agree that your disaster plan leaves a bit to be desired, but I reckon you'll be ok this time...

So first thing is that Apache appears to just be rendering the PHP code as text, rather than processing it and rendering the resultant HTML. I suspect that is caused by you no longer having an Apache PHP module installed and/or enabled.

Before I go any further, I am working on the assumption that you are going back to the Debian defaults. To ensure that works as it should, be sure to disable the third party PHP related apt sources.list. IIRC it should be called 'php.list'. If you get errors about file not found, please double check what the right name of the file is (in /etc/apt/sources.list.d). Assuming it's 'php.list':

mv /etc/apt/sources.list.d/php.list /etc/apt/sources.list.d/php.list.disabled

Then update apt sources (so knowledge of all third party packages is cleared):

apt update

Then make sure that the correct Apache PHP module is installed and enabled:

apt install --reinstall libapache2-mod-php
a2enmod php
systemctl restart apache2

Fingers crossed, that should be it...


It just occurred to me that I didn't mention the logs that you posted at all... Sorry about that.

I covered the PHP file just being displayed (i.e. rendered as raw test, rather than processed).

The Apache log doesn't show us anything of value. The 'AH01909' warnings are just because Apache is using the servername of localhost, but doesn't have a SSL cert for that.

On face value, the Nextcloud log doesn't give us anymore info than the Apache log. Although, I did just notice that the last line might be of interest? Let me render the contents in a way that makes it easier to read:

{
"Exception":"OCP\\AppFramework\\QueryException",
"Message":"Could not resolve trashManager! Class trashManager does not exist",
"Code":0,
"Trace":
[{
    "file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",
    "line":126,
    "function":"resolve",
    "class":"OC\\AppFramework\\Utility\\SimpleContainer",
    "type":"->",
    "args":["trashManager"]
},{
    "file":"/var/www/nextcloud/lib/private/ServerContainer.php",
    "line":162,
    "function":"query",
    "class":"OC\\AppFramework\\Utility\\SimpleContainer",
    "type":"->",
    "args":["trashManager",true]
},{
    "file":"/var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php",
    "line":434,
    "function":"query",
    "class":"OC\\ServerContainer",
    "type":"->",
    "args":["trashManager",true]
},{
    "file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php",
    "line":56,
    "function":"query",
    "class":"OC\\AppFramework\\DependencyInjection\\DIContainer",
    "type":"->","args":["trashManager"]
},{
    "file":"/var/www/nextcloud/lib/private/AppFramework/Bootstrap/FunctionInjector.php",
    "line":58,
    "function":"get",
    "class":"OC\\AppFramework\\Utility\\SimpleContainer",
    "type":"->","args":["trashManager"]
},{
    "function":"OC\\AppFramework\\Bootstrap\\{closure}",
    "class":"OC\\AppFramework\\Bootstrap\\FunctionInjector",
    "type":"->",
    "args":["*** sensitive parameters replaced ***"]
},{
    "file":"/var/www/nextcloud/lib/private/AppFramework/Bootstrap/FunctionInjector.php",
    "line":68,
    "function":"array_map",
    "args":[
        {"__class__":"Closure"}, [
            {"name":"serverContainer","__class__":"ReflectionParameter"},
            {"name":"logger","__class__":"ReflectionParameter"},
            {"name":"appManager","__class__":"ReflectionParameter"},
            "*** sensitive parameter replaced ***"
        ]
    ]
},
    {"file":"/var/www/nextcloud/lib/private/AppFramework/Bootstrap/BootContext.php",
    "line":52,
    "function":"injectFn",
    "class":"OC\\AppFramework\\Bootstrap\\FunctionInjector",
    "type":"->",
    "args":[[
            {"__class__":"OCA\\Files_Trashbin\\AppInfo\\Application"},
            "registerTrashBackends"
    ]]
},{
    "file":"/var/www/nextcloud/apps/files_trashbin/lib/AppInfo/Application.php",
    "line":57,
    "function":"injectFn",
    "class":"OC\\AppFramework\\Bootstrap\\BootContext",
    "type":"->",
    "args":[[
            {"__class__":"OCA\\Files_Trashbin\\AppInfo\\Application"},
            "registerTrashBackends"
    ]]
},{
    "file":"/var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php",
    "line":176,
    "function":"boot",
    "class":"OCA\\Files_Trashbin\\AppInfo\\Application",
    "type":"->",
    "args":[{"__class__":"OC\\AppFramework\\Bootstrap\\BootContext"}]
},{
    "file":"/var/www/nextcloud/lib/private/legacy/OC_App.php",
    "line":197,
    "function":"bootApp",
    "class":"OC\\AppFramework\\Bootstrap\\Coordinator",
    "type":"->",
    "args":["files_trashbin"]
},{
    "file":"/var/www/nextcloud/lib/private/legacy/OC_App.php",
    "line":137,
    "function":"loadApp",
    "class":"OC_App",
    "type":"::",
    "args":["files_trashbin"]
},{
    "file":"/var/www/nextcloud/apps/dav/lib/AppInfo/Application.php",
    "line":124,
    "function":"loadApps",
    "class":"OC_App",
    "type":"::",
    "args":[["dav"]]
},{
    "file":"/var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php",
    "line":176,
    "function":"boot",
    "class":"OCA\\DAV\\AppInfo\\Application",
    "type":"->",
    "args":[{"__class__":"OC\\AppFramework\\Bootstrap\\BootContext"}]
},{
    "file":"/var/www/nextcloud/lib/private/legacy/OC_App.php",
    "line":197,
    "function":"bootApp",
    "class":"OC\\AppFramework\\Bootstrap\\Coordinator",
    "type":"->",
    "args":["dav"]
},{
    "file":"/var/www/nextcloud/lib/private/legacy/OC_App.php",
    "line":137,
    "function":"loadApp",
    "class":"OC_App",
    "type":"::",
    "args":["dav"]
},{
    "file":"/var/www/nextcloud/lib/private/legacy/OC_Util.php",
    "line":203,
    "function":"loadApps",
    "class":"OC_App",
    "type":"::",
    "args":[["filesystem"]]
},{
    "file":"/var/www/nextcloud/lib/private/User/Session.php",
    "line":554,
    "function":"setupFS",
    "class":"OC_Util",
    "type":"::",
    "args":["*** sensitive parameter replaced ***"]
},{
    "file":"/var/www/nextcloud/lib/private/User/Session.php",
    "line":415,
    "function":"prepareUserLogin",
    "class":"OC\\User\\Session",
    "type":"->",
    "args":[true,"*** sensitive parameter replaced ***"]
},{
    "file":"/var/www/nextcloud/lib/private/User/Session.php",
    "line":624,
    "function":"completeLogin",
    "class":"OC\\User\\Session",
    "type":"->",
    "args":["*** sensitive parameters replaced ***"]
},{
    "file":"/var/www/nextcloud/lib/private/User/Session.php",
    "line":367,
    "function":"loginWithPassword",
    "class":"OC\\User\\Session",
    "type":"->",
    "args":["*** sensitive parameters replaced ***"]
},{
    "file":"/var/www/nextcloud/lib/private/Setup.php",
    "line":440,
    "function":"login",
    "class":"OC\\User\\Session",
    "type":"->",
    "args":["*** sensitive parameters replaced ***"]
},{
    "file":"/var/www/nextcloud/core/Command/Maintenance/Install.php",
    "line":108,
    "function":"install",
    "class":"OC\\Setup",
    "type":"->",
    "args":["*** sensitive parameters replaced ***"]
},{
    "file":"/var/www/nextcloud/3rdparty/symfony/console/Command/Command.php",
    "line":255,
    "function":"execute",
    "class":"OC\\Core\\Command\\Maintenance\\Install",
    "type":"->",
    "args":[
        {"__class__":"Symfony\\Component\\Console\\Input\\ArgvInput"},
        {"__class__":"Symfony\\Component\\Console\\Output\\ConsoleOutput"}
    ]
},{
    "file":"/var/www/nextcloud/3rdparty/symfony/console/Application.php",
    "line":1009,
    "function":"run",
    "class":"Symfony\\Component\\Console\\Command\\Command",
    "type":"->",
    "args":[
        {"__class__":"Symfony\\Component\\Console\\Input\\ArgvInput"},
        {"__class__":"Symfony\\Component\\Console\\Output\\ConsoleOutput"}
    ]
},{
    "file":"/var/www/nextcloud/3rdparty/symfony/console/Application.php",
    "line":273,
    "function":"doRunCommand",
    "class":"Symfony\"nextcloud.log" 2L, 14241C

That last bit suggests that the output has been truncated (i.e. isn't the whole output). In case you aren't aware, this is a PHP stacktrace. I'm not super familiar with PHP, but my guess is that it's just the backend details of the 50x error that the front end is reporting. I think that you need to get PHP working properly and ensure that is right before you start worrying about that too much.

Hopefully my other posts help with that...

Francisco's picture

Hi Jeremy, I continue with the same "Internal Server Error".  Meanwhile, with the validations to post here and the timezones, I've opened the following topic in NextCloud support forum.
https://help.nextcloud.com/t/after-php-upgrade-cant-access-nextcloud-anymore-internal-server-error/144969
I still don't have access to NextCloud, and my data. Could you please help? Highly appreciate your support.
Jeremy Davis's picture

A 50x error relates to something on the backend not responding as it should. The most common cause of that is when the front end server is simply acting as a reverse proxy and the backend server is not responding (or not responding properly). In my experience, 50x errors are uncommon when using Apache mod_php, although if there is some serious PHP misconfiguration then perhaps?

Try reinstalling and re-enabling mod_php as per my previous post. If that still doesn't work, please then please paste back with the latest from your Apache and Nextcloud logs.


I just realised that I didn't discuss the logs you posted (and actually, I didn't look at them properly). I'll update the previous post.

Francisco's picture

Jeremy, found this here - it solved my issue:

sudo a2dismod mpm_event
sudo systemctl restart apache2
sudo a2dismod mpm_worker
sudo systemctl restart apache2
sudo a2enmod mpm_prefork
sudo systemctl restart apache2
sudo a2enmod php8.0
sudo systemctl restart apache2

Thank you so much for the help. Finally I've my stuff back again. :)

Jeremy Davis's picture

I'm glad to hear that that solved your issue, although the only line that should have made any difference was this one:

a2enmod php8.0

That enables Apache's PHP 8.0 module. So you're now using PHP 8.0. FWIW, installing the package 'libapache2-mod-php8.0' should auto enable it as part of the install process. So it should have "just worked". Obviously it didn't for you. I'm not completely sure why, but it's good to know. Perhaps we should document running that line explicitly anyway (if it happens automatically, re-running it won't cause any issue)?

Anyway, glad to hear that you are back up and running. Now go and set up backups! :)

Francisco's picture

I'm sure that I've run that line the first time. But I saw that I got some issues with those mpm "services". I had also now some issues with crontab job; permissions and php max memory. Previously everything was fine, but I don't know what happened during this update that messed up so much stuff. Just finished fixing those but tomorrow I'll do my best to setup some backup strategy, starting to learn more about your suggestion of TKLBAM and how it works. Now it's already quite late and I can't snooze my wife's complaints anymore. Really appreciate the help!! ;) 
Jeremy Davis's picture

Each PHP version has it's own php.ini file (actually, there are cli and apache php.ini files for each version). So when you upgrade PHP, you get new default php.ini files. So you'll need to update the relevant php.ini file(s) to apply your settings to the new relevant php.ini file. FWIW, the paths should be something like this:

/etc/php/PHP_VERSION/apache2/php.ini
/etc/php/PHP_VERSION/cli/php.ini

Where PHP_VERSION is the PHP version you are using. I.e. now you have PHP 8.0, the paths will be:

/etc/php/8.0/apache2/php.ini
/etc/php/8.0/cli/php.ini

Updates to the CLI php.ini should be applied instantly. Changes to the Apache2 php.ini will require an Apache restart. I.e.:

systemctl restart apache2

Good luck with it.

Add new comment