Can not install nextcloud in new server

this version of Nextcloud is not compatible with > PHP 8.0.
You are currently running 8.1.3.Sorry but something went wrong. Please report this issue to Issues · nextcloud/vm · GitHub and include the output of the error message. Thank you!
sudo -u www-data php /var/www/nextcloud/occ maintenance:install --data-dir=/mnt/ncdata --database=pgsql --database-name=nextcloud_db --database-user=ncadmin --database-pass=v0YU8PIsGrYkS0xqTQ#XjOegB --admin-user=ncadmin --admin-pass=nextcloud failed
Checking connection…

Please fill out the support form

Debian/Ubuntu apt based linux.

The solution is: install php 8.0.x and all php modules required…

apt-get install php8.0-module_name_here

You will have 2 php installed on your server. The “bad” 8.1 active and the “good” 8.0 inactive
After having installed all php8.0-xxxx , tou need to deactivate php8.1, and activate php8.0 using the following command:
php -v to check the active version, 8.1 in your case: PHP 8.1.xx (cli)

a2dismod php8.1
a2enmod php8.0

php -v and you should see : PHP 8.0.xx (cli)

Warning: you will have /etc/php/ populated with 8.0 and 8.1
If php-v = 8.0.xx then your php.ini or php.conf are under /etc/php/8.0/

Here is my module list on Debian 11.3

[PHP Modules]
apcu
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
igbinary
imagick
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

If you want to uninstall/purge php8.1, do it before installing php8.0 using:

apt-get purge php8.1-*

Purging php8.1 may break some dependencies, so you may have to reinstall some packages

Makes sense. php 8.1 is not supported by Nextcloud yet. No idea how you ended up installing it, but you obviously discovered that it is simply not supported. Eventually it will be. Cheers!

Actually, this is a little bit wrong… there a way to do it, but it is not yest supported…