PHP 8 on Debian 11

PHP 8 is not available in the Debian 11 repositories and needs to be installed manually:

Add repo:

apt-get update
apt-get install ca-certificates apt-transport-https software-properties-common -y
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/sury-php.list
wget -qO - https://packages.sury.org/php/apt.gpg | apt-key add -
apt-get update -y

apt-get install php8.0
php -v

Add required extensions (adjust as necessary):

apt-get install php php-common php-xml php-gd php-mbstring php-tokenizer php-json php-bcmath php-zip -y

Configure PHP and adjust Apache:

vi /etc/php/8.0/apache2/php.ini
#Change the following lines:
upload_max_filesize = 32M 
post_max_size = 48M 
memory_limit = 256M 
max_execution_time = 600 
max_input_vars = 3000 
max_input_time = 1000

a2dismod php7.4
a2enmod php8.0
systemctl restart apache2

Test PHP

vi /var/www/html/info.php
<?php phpinfo(); ?>