php8 delivers up to +25% better speed than php7, which is remarkable.

follow this excellent guide, and how to upgrade apache2 based webservers from php7 to php8.1, simply replace php8.0 with php8.1 in this excellent guide guide:

in short:

su - root
apt update
apt install ca-certificates apt-transport-https software-properties-common gnupg2
wget -qO - | apt-key add -
apt update

# checkout what versions are available
apt search php8|less

# install it
apt install php8.1

# only install the php extensions that are required
apt install php8.1-mysql php8.1-curl php8.1-gd php8.1-intl php-pear php-imagick php8.1-imap php-memcache php8.1-pspell php8.1-sqlite3 php8.1-tidy php8.1-xmlrpc php8.1-xsl php8.1-mbstring

# activate php8.1
a2dismod php7.4
a2enmod php8.1
systemctl restart apache2

follow the awesome developer on twitter who makes this stuff happen!

(for whatever reason, there are no official php8 packages in Debian 11 yet)

might hold usefull info:

reply from mailing list:

encountered errors & ugly workaround fix:

as there is (still in 2022-06 no official debian/ubuntu php8.1 package in the official repo):


apt update

which results in the user being unable to install any further apt packages
(bad, bad, bad, time that php8.X shows up in official Debian repo)

dpkg --configure -a
Setting up libapache2-mod-php8.1 (8.1.7-1+0~20220614.21+debian11~1.gbpb08a43) ...
/var/lib/dpkg/info/libapache2-mod-php8.1.postinst: 49: /etc/apache2/envvars: clear_env: not found
dpkg: error processing package libapache2-mod-php8.1 (--configure):
 installed libapache2-mod-php8.1 package post-installation script subprocess returned error exit status 127
dpkg: dependency problems prevent configuration of php8.1:
 php8.1 depends on libapache2-mod-php8.1 | php8.1-fpm | php8.1-cgi; however:
  Package libapache2-mod-php8.1 is not configured yet.
  Package php8.1-fpm is not installed.
  Package php8.1-cgi is not installed.

dpkg: error processing package php8.1 (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:

# which seems to stem from
apache2ctl restart
/usr/sbin/apache2ctl: 49: /etc/apache2/envvars: clear_env: not found
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using Set the 'ServerName' directive globally to suppress this message

# while this does not return any errors
systemctl restart apache2
# unless the user follows the logs (with this neat debug-em-all-one-liner), which show the same error

# test if apache2 -> works never the less
telnet 80
Connected to
Escape character is '^]'.

# workaround, in this script
vim /var/lib/dpkg/info/libapache2-mod-php8.1.postinst

# set -e <- comment out this line

if [ -e /usr/share/apache2/apache2-maintscript-helper ]; then
. /usr/share/apache2/apache2-maintscript-helper

php_enable() {
local a2query_ret=0
a2query -m "php8.1" > /dev/null 2>&1 || a2query_ret=$?

# which is (of course) an ugly workaround because it simply means "ignore all errors in this script"
help set | grep Exit
-e Exit immediately if a command exits with a non-zero status.

# then run
apt update
apt install wanted-package

# have phun

more or less related links:

how to setup basic LAMP stack GNU Linux Debian – (Apache2 php7.3 MariaDB) (how to install xdebug – step debugging php requests in eclipse pdt on debian 10 buster (LAMP web development stack))