- Make sure your system is up to date
sudo apt update && sudo apt upgrade -y
- Create user
sudo useradd -m -U -r -d /opt/magento magento && sudo chmod 750 /opt/magento
See this tutorial to add repos and upgrade to new versions: https://thishosting.rocks/install-php-on-ubuntu/