First, install the required dependencies using the following command:
sudo apt-get install gnupg2 ca-certificates apt-transport-https software-properties-common -y
Next, add the PHP Sury repository to APT and add the GPG key with the following command:
sudo echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
sudo wget -qO - https://packages.sury.org/php/apt.gpg | apt-key add -
Next, update the repository and install PHP 8.0 with all necessary PHP extensions needed using the following command:
sudo apt-get update -y
sudo apt-get install php libapache2-mod-php php-pear php-cgi php-common php-mbstring php-zip php-net-socket php-gd php-xml-util php-curl php-imagick php-mysql php-bcmath unzip wget git -y
You can now check the PHP version using the command below:
php -v
Referenece:
https://cloudinfrastructureservices.co.uk/install-wordpress-on-debian-10-11/