Updating WordPress / Divi to PHP8.1.x on Ubuntu 20.04

Written by James McDonald

February 23, 2022

So have installed PHP8.1 from ondrej PPA

sudo add-apt-repository ppa:ondrej/php

Install PHP8.1

sudo apt install php8.1-fpm
sudo apt install php8.1
sudo apt install php8.1-intl
sudo apt install php8.1-mbstring
sudo apt install php8.1-mysql
sudo apt install php8.1-xml
sudo apt install php8.1-zip
sudo apt install php8.1-opcache
sudo apt install php8.1-curl
sudo apt install php8.1-mailparse
sudo apt install php8.1-imagick
# or for greater brevity with bash shell

sudo apt install php8.1-{fpm,intl,mbstring,curl,mailparse,imagick,zip,xml,mysql}

The first thing I found is that /etc/php/8.1/fpm/php-fpm.conf is missing when I try to start the php8.1-fpm.service

# copy it from 8.0 and edit
cp /etc/php/8.0/fpm/php-fpm.conf /etc/php/8.1/fpm/php-fpm.conf

# find and replace all instances of 8.0 with 8.1 then
systemctl enable php8.1-fpm.service
systemctl start php8.1-fpm.service

The next challenge is when trying to enable the needed extensions. I get these errors

phpenmod -v 8.1 intl
WARNING: Module intl ini file doesn't exist under /etc/php/8.1/mods-available
WARNING: Module intl ini file doesn't exist under /etc/php/8.1/mods-available

The fix is copying the ini files to the mods-available directory to make them available to php8.1-fpm

Find and enable the PHP extensions you need

WordPress docs has a list of recommended extensions => https://make.wordpress.org/hosting/handbook/server-environment/

 cp /usr/share/php8.1-mysql/mysql/*.ini /etc/php/8.1/mods-available
phpenmod -v 8.1 mysqli
phpenmod -v 8.1 mysqlnd
phpenmod -v 8.1 pdo_mysql

cp /usr/share/php8.1-opcache/opcache/opcache.ini /etc/php/8.1/mods-available/
phpenmod -v 8.1 opcache

cp /usr/share/php8.1-common/common/* /etc/php/8.1/mods-available/
phpenmod -v 8.1 ctype

# repeat for all your needed modules & restart 
systemctl restart php8.1-fpm.service

To find out what is missing browse your WordPress site and trigger errors. You might see error screens like the following:

The emails sent to your site admin email address will contain hints as to what’s missing. The following says I’m missing the ctype extension

To see the PHP extensions you have enabled

 ls -1 /etc/php/8.1/fpm/conf.d/ 


Submit a Comment

Your email address will not be published.

You May Also Like…

List your VSCode Extensions

Ever wondered what extensions you have installed and want to keep a list? This actually is a good way to audit your...

array_merge vs the + operator

<?php $options = [ 'rootNode' => 'response' ]; // array_merge // the same key appearing later will overwrite echo...