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

So have installed PHP8.1 from…

Login

Blog History

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/ 
10-mysqlnd.ini
10-opcache.ini
20-ctype.ini
20-curl.ini
20-gd.ini
20-imagick.ini
20-intl.ini
20-mbstring.ini
20-mysqli.ini
20-pdo_mysql.ini
20-soap.ini
20-tidy.ini
20-zip.ini

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.