Yeah it seems like a bad idea to install something that VM uses/manages prior to installing VM, that’s bound to break the system or to cause issues.
The issue is that VM needs to be installed on a virgin OS before you install anything. I just tested that idea with the version 6 installer and as expected VM uninstalls it and installs MySQL (and will just about break the system too). To install MariaDB on 20.04 with the version 6 installer you first install Virtualmin, then remove MySQL, install MaraDB, re-check configuration, and then run the post-install wizard in Virtualmin.
The only things that are safe to install before you install Virtualmin is software that has nothing to do with VM or Webmin that it doesn’t know about and won’t touch, and I imagine that’s much the same for any server control panel.
If you’re intending to use your VPS in production or you need stability, I’d recommend Ubuntu 20.04 LTS, and upgrade later once you know that 22.04 is fully supported and can be safely upgraded.
The version 6 installation route for Ubuntu 20.04 LTS + MariaDB + PHP 8.1, I’ve just tested this fully on a fresh VPS:
sudo add-apt-repository ppa:ondrej/php
sudo add-apt-repository ppa:ondrej/nginx
sudo apt update
apt list --upgradable
sudo apt full-upgrade
sudo /bin/rm -v /etc/ssh/ssh_host_*
sudo dpkg-reconfigure openssh-server
sudo timedatectl set-timezone Australia/Sydney
reboot
wget https://software.virtualmin.com/gpl/scripts/install.sh
sudo /bin/sh install.sh -m -f -n host.example.org -b LEMP
sudo systemctl stop mysql
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*
sudo rm -Rf /etc/mysql /var/lib/mysql /var/log/mysql
sudo apt autoremove
echo "/usr/sbin/mysqld { }" > /etc/apparmor.d/usr.sbin.mysqld
apparmor_parser -v -R /etc/apparmor.d/usr.sbin.mysqld
sudo apt install mariadb-server
sudo apt-get install php8.1-{curl,pdo,fpm,zip,gd,xml,xmlrpc,mysql,common,mbstring,imagick}
sudo apt-get purge php5.6-{cli,pdo,fpm,zip,gd,xml,mysql,cgi} php7.*-{cli,pdo,fpm,zip,gd,xml,mysql,cgi} php8.0-{cli,pdo,fpm,zip,gd,xml,mysql,cgi}
sudo apt-get autoclean
sudo apt-get autoremove
reboot
If you get a prompt asking if you wish to overwrite /etc/apparmor.d/usr.sbin.mysqld
when you install MariaDB select Yes. Because I added the ppa:ondrej/php
repo before installing VM it installed every version of PHP found there from 5.6 to 8.1, if you prefer you can install VM first then add the repo and install php 8.1 with the same command as above and you should only need to remove version 7.4 in that case which is the version provided by the Focal repo (Ubuntu 20.04’s repo). You can simplify the steps above of course if you want (and note I’m installing the minimal version with LEMP stack with my install command).
Now before you run the post-install wizard in Virtualmin run “Re-Check Configuration”, reboot the VPS (this may not be strictly necessary but it won’t hurt), and then run the post-install wizard.