Activate http/2 or http/3 with apache webserver not working

For Apache2 you only have the alternative to use php-fpm.

Based on your installation (Ubuntu 22.04) and your php Version (8.1) I would advise you to simply install php8.1-fpm:

sudo apt-get install php8.1-fpm

Then install the → php-updater script ← and simply run it.
It will detect unnecessary packages and make an offer to clean them up. It will detect, that you have both SAPI’s installed and ask, if you want to change from libapache2-mod-php8.1 to php8.1-fpm. Let the script change the SAPI.

After that, if everything works correctly, you can easily use the script to update to a newer PHP version (8.2) if you want.


Much and good luck,
ernolf