#First perform and apt update
sudo apt update && sudo apt upgrade -y
#Install dependencies
sudo apt install software-properties-common apt-transport-https -y
#Add the PPA
sudo add-apt-repository ppa:ondrej/php -y
#Now to install PHP 8.1 FPM and it's modules
sudo apt install php8.1-fpm php8.1-common php8.1-mysql php8.1-xml php8.1-xmlrpc php8.1-curl php8.1-gd php8.1-imagick php8.1-cli php8.1-dev php8.1-imap php8.1-mbstring php8.1-opcache php8.1-soap php8.1-zip php8.1-intl php8.1-bcmath
# Ubuntu 20.04
# List existing PHP packages
dpkg -l | grep php | tee packages.txt
#Add ondrej/php PPA
sudo add-apt-repository ppa:ondrej/php # Press enter when prompted.
sudo apt-get update
#Install PHP 8.0 with CLI
sudo apt install php8.0-common php8.0-cli
#Additional extensions
sudo apt install php8.0- { bz2,curl,intl,mysql,readline,xml }
sudo apt install php8.0-cli php8.0-common php8.0-imap php8.0-redis php8.0-snmp php8.0-xml
sudo apt install php8.0
sudo apt update
sudo apt install lsb-release ca-certificates apt-transport-https software-properties-common -y
sudo add-apt-repository ppa:ondrej/php
sudo apt install php8.0 libapache2-mod-php8.0