Install PHP 7.4 and 8.x on Debian and Ubuntu🔗

Update the system

apt update && apt upgrade -y

Install Sury's repo

apt -y install lsb-release apt-transport-https ca-certificates
# Debian
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
# Ubuntu
add-apt-repository ppa:ondrej/php
# Continue
apt update

Install PHP

apt install libapache2-mod-php{7.4,8.0,8.1,8.2,8.3} php{7.4,8.0,8.1,8.2,8.3} php{7.4,8.0,8.1,8.2,8.3}-{bcmath,cli,common,curl,fpm,gd,imap,intl,ldap,mbstring,mysql,opcache,readline,soap,xml,xmlrpc,zip} php7.4-json

Done!