Updating old Nextcloud instance / different PHP versions

Hello,

I am confronted with an older Nextcloud instance that needs to be updated.
Current:
Ubuntu Server 20.04
PHP 7.2 and 7.4 installed
php -v: PHP 7.4.3
Hosted with nginx on the same server
Nextcloud version: 25.0.5

So I need to bring it to:
PHP 8.1 (or higher?)
Nextcloud latest (29.0.4?)
Ubuntu 24.04 (or at least 22.04)

I tried updating to Ubuntu 22.04, ended up with 502 Bad Gateway.
I think this is most likely due to PHP update to 8.1 in 22.04.

Now, I’ve tried search for relevant tutorials, and I’ve found how to update from 7.4 to 8.1, however only based on Apache.

What I am missing is the way how to do it in conjunction with nginx and php 8.1.

Can you recommend me which way I should go, which components to update first, 2nd etc?
Also, which PHP and Ubuntu version should I aim for?

Thanks
Srdan

The only real difference for Apache versus Nginx is you’ll be updating the php-fpm instead (and the fpm socket path may need to be updated in your nginx config).

The high-level approach is the same.

I’m fairly certain there are various people that have updated fpm in the archives here.