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 - https://packages.sury.org/php/apt.gpg | 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

https://www.howtoforge.com/how-to-install-php-8-on-debian-11/

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: https://phptherightway.com/

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):

during

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:
 libapache2-mod-php8.1
 php8.1

# 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 127.0.1.1. Set the 'ServerName' directive globally to suppress this message

# apache2 restarts never the less which can be checked either by browser http://localhost or telnet
# 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 127.0.0.1 80
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.

# 1) workaround:
# open up
vim /etc/apache2/envvars
# modify the following line from this:
clear_env = false
# to this
clear_env=false

# this is CLEARLY a typo, because instead of asigning the variable clear_env the value false
# what it does (because of the spaces before = and after = )
# is search for a command with the name clear_env (which does not exist)
# hence the error
# 2) ugly ugly workaround:
vim /var/lib/dpkg/info/libapache2-mod-php8.1.postinst
#!/bin/sh

# 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! :D

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))

from user to dev:

  • the positive:
    • php is easy to learn
    • php is usually “fast enough” (for web backends: it is slower than java but faster than python, but java needs A LOT more RAM)
    • php related environments might be a wee bit complicated to setup
  • if the user wants to become a php dev check out bro’s excellent fun and easy php examples 🙂
    • just4info:
      • all those fancy php frameworks symphony sometime consisting of more than 10.000 files (thanks for making it open source but that’s a wee bit against unix kiss)
      • are just libraries that a dev wrote to use it, and while it HIGHLY might advance the user-soon-php-dev php-related-career they are NOT REQUIRED to get started, also:
        • if the user-soon-php-dev writes libraries + uses xdebug, the user-soon-php-dev is the only one who REALLY understands whats going on “under the hood” why things work or fail

keep it up and running:

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!
admin