Best way to upgrade php, Ubuntu and NC-version

My production server is currently on NC20.0.14 , php7.3, Ubuntu 18.04. In the near future I plan to upgrade the NC to at least NC22. As php7.3 has reached EOL I need to upgrade that as well. And I think I may just as well upgrade Ubuntu at the same time.

I can upgrade the current version to NC22, and then also upgrade php and Ubuntu. Or I can setup a clean installation with NC22, php8.0 and Ubuntu20 and migrate the current data to that one.

I know the instruction here
but I think this is only migrating to another server with same NC, php, Ubuntu. Will it work if I migrate to a server with upgraded php and ubuntu?

Is there any “How to instructions” for upgrading php and ubuntu?

you have to upgrade NC first to 21 and afterwards to 22 … see version.php of NC 22.2.3:

$OC_VersionCanBeUpgradedFrom = [
‘nextcloud’ => [
‘21.0’ => true,
‘22.0’ => true,
‘22.1’ => true,
‘22.2’ => true,
‘owncloud’ => [
‘10.5’ => true,

You can also setup a new NC, PHP and migrate afterwards - long story very short:

  1. install new server with e.g. Ubuntu 20.04, PHP8 - but stick with the database … (i run debian 11, php7.4 and postgres13)
  2. sync the data-dir to the new server
  3. dump the db and import it on new server