State of this doc: written while trying to do that for the first time

For that we use php8.1-fpm. It would also be possible to do the same for php8.2 but haven't tried yet. See /root/Changelog (2023-01-06) to see how PHP8 was installed.

  • Create a new php8.1-fpm pool for the website
    • cd /etc/php/8.1/fpm/pool.d/
    • cp www.conf.disabled WEBSITE_USER.conf
      • WEBSITE_USER should be replaced by the username the website runs as
  • Edit this config file and change these lines:
    • Third line, the value between square brackets
    • user= should be the username the website runs as (as specificied in apache config)
    • group= same
    • listen= should be /run/php/php8.1-fpm-WEBSITE_USER.sock
      • Replace WEBSITE_USER
    • listen.owner= and listen.group= should also be set to that user
  • Reload php-fpm
    • systemctl reload php8.1-fpm
  • Tell the site to use PHP8
    • Edit the site's .htaccess and add these: <FilesMatch \.php$> <If "-f %{REQUEST_FILENAME}"> SetHandler "proxy:unix:/run/php/php8.1-fpm-WEBSITE_USER.sock|fcgi://localhost/" </If> </FilesMatch>
    • Replace WEBSITE_USER by the correct value set earlier