12.13.2022:  PHP 8.2.0 was updated to both my WordPress servers.
1.7.2023:  Upgraded the server to php 8.2.1.   So far it is working good.  So far all the web sites are working.
2.7.2023: PHP 8.2.2 is working great on WordPress and the plugins. 
8.20.2023: PHP 8.2.9 is working great on WordPress and the plugins. 

/etc/php/8.2/fpm$

fpm.conf
error_log = /var/log/php8.1/php8.2-fpm.log

php-fpm.conf
error_log = /var/log/php8.2/php8.2-fpm.log

/etc/logrotate.d/php8.2-fpm.conf
/var/log/php8.2/php8.2-fpm.log {
rotate 12
weekly
missingok
notifempty
compress
delaycompress
postrotate
if [ -x /usr/lib/php/php8.1-fpm-reopenlogs ]; then
/usr/lib/php/php8.1-fpm-reopenlogs;
fi
endscript
}

 

PHP Compatibility and WordPress Versions

WordPress aims to support new versions of PHP on the day they are released as much as possible. As a project, the process of supporting these new versions begins after each new PHP version has hit feature freeze and are tagging beta versions. This prevents having to revert or make additional changes to WordPress if a planned feature is removed or the implementation changes.

Past changes to supported PHP versions have been as followed:

  • In WordPress version 4.1: Added support for PHP 5.6.
  • In WordPress 4.4: Added support for PHP 7.0 (dev note).
  • In WordPress 4.7: Added support for PHP 7.1.
  • In WordPress 4.9: Added support for PHP 7.2.
  • In WordPress 5.0: Added support for PHP 7.3 (dev note).
  • In WordPress 5.2: Dropped support for PHP 5.2, 5.3, 5.4, 5.5.
  • In WordPress 5.3: Added support for PHP 7.4 (dev note).
  • In WordPress 5.6: Added “beta support” for PHP 8.0 (dev note).
Both WordPress servers are now on PHP 8.x. 

See the WordPress page for some other php fixes. 

See the http/2 section at bottom.

This will setup the repository for php to be on the latest version

sudo apt-get update && apt-get upgrade
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo add-apt-repository ppa:ondrej/apache2
sudo apt update

Find all PHP files installed

dpkg -l | grep php | tee packages.txt

Clean up old versions of PHP

sudo apt-get purge php5.6 libapache2-mod-php5.6 php5.6-common php5.6-mysql php5.6-gmp php5.6-curl php5.6-intl php5.6-mbstring php5.6-xmlrpc php5.6-gd php5.6-xml php5.6-cli php5.6-zip php5.6-bcmath php5.6-imagick php5.6-fpm

sudo apt-get purge php7.0 libapache2-mod-php7.0 php7.0-common php7.0-mysql php7.0-gmp php7.0-curl php7.0-intl php7.0-mbstring php7.0-xmlrpc php7.0-gd php7.0-xml php7.0-cli php7.0-zip php7.0-bcmath php7.0-imagick php7.0-fpm

sudo apt-get purge php7.1 libapache2-mod-php7.1 php7.1-common php7.1-mysql php7.1-gmp php7.1-curl php7.1-intl php7.1-mbstring php7.1-xmlrpc php7.1-gd php7.1-xml php7.1-cli php7.1-zip php7.1-bcmath php7.1-imagick php7.1-fpm

sudo apt-get purge php7.2 libapache2-mod-php7.2 php7.2-common php7.2-mysql php7.2-gmp php7.2-curl php7.2-intl php7.2-mbstring php7.2-xmlrpc php7.2-gd php7.2-xml php7.2-cli php7.2-zip php7.2-bcmath php7.2-imagick php7.2-fpm

sudo apt-get purge php7.3 libapache2-mod-php7.3 php7.3-common php7.3-mysql php7.3-gmp php7.3-curl php7.3-intl php7.3-mbstring php7.3-xmlrpc php7.3-gd php7.3-xml php7.3-cli php7.3-zip php7.3-bcmath php7.3-imagick php7.3-fpm php7.3-bz2 php7.3-mcrypt

sudo apt-get purge php8.1 libapache2-mod-php8.1 php8.1-common php8.1-mysql php8.1-gmp php8.1-curl php8.1-intl php8.1-mbstring php8.1-xmlrpc php8.1-gd php8.1-xml php8.1-cli php8.1-zip php8.1-bcmath php8.1-imagick php8.1-fpm php8.1-bz2 php8.1-mcrypt

Install newest version of PHP

sudo apt install php8.2 libapache2-mod-php8.2 php8.2-common php8.2-mysql php8.2-gmp php8.2-curl php8.2-intl php8.2-mbstring php8.2-xmlrpc php8.2-gd php8.2-xml php8.2-cli php8.2-zip php8.2-bcmath php8.2-imagick php8.2-fpm php8.2-bz2 php8.2-mcrypt

remove old fpm
sudo a2disconf php8.1-fpm

replace fpm
sudo a2enconf php8.2-fpm

This is what I use to install PHP for WordPress.

This is how you activate your new PHP files.
sudo a2dismod php8.1
sudo a2enmod php8.2
sudo service apache2 restart
Which PHP files are on my server: You can use it to clean up older files you don’t need
dpkg -l | grep php | tee packages.txt
Purge old php files

php 8.2 configuration

Site health will show PHP issues.  Elementor – System Info will show up your php version and configuration.

I have been working on better securing my web sites in WP.   I installed the Health Check plugin.   I did add them into the commands to install above. 

It checked the php components and found a few missing. CURL, which I had installed so I refollowed these steps to verify it for php 7.3

First Install CURL by typing sudo apt-get install curl
Then Restart Apache by typing sudo service apache2 restart

Then Install PHP7.4 CURL by typing sudo apt-get install php7.4-curl

will prompt to install… type y or yes!

Then Restart Apache by typing sudo service apache2 restart

Done!  It now shows up in phpMyAdmin.

I have upgraded to the latest LAMP components that you are read about on Ubuntu pages.   I am on the latest version of WordPress.   This mainly affects my main webpage with videos of my children.  These files can be huge so I set the limits at 768MB.  Ubuntu server has 2 GB RAM available.

/etc/php/8.2/fpm/php.ini
/etc/php/8.2/cli/php.ini
/etc/php/8.2/apache2/php.ini

upload_max_filesize = 768M
post_max_size =768M memory_limit = 768M max_execution_time = 360
mysqli.allow_local_infile = On

Health Check said these two components were missing.  fpm had some errors too.

I ran the commands below in various order to fix fpm

sudo a2enmod proxy_fcgi setenvif
sudo a2disconf php8.1-fpm
sudo a2enconf php8.1-fpm sudo apt purge libapache2-mod-php8.1 libapache2-mod-php
sudo apt install libapache2-mod-php8.1 libapache2-mod-php

After I fixed these errors, I ran update and dist-upgrade again to get the latest versions. 

Enabling http/2 for Apache2:
You need to remove mpm_prefork and put in mpm_event

mpm_prefork doesn’t support http/2.
You need to disable php7.x first.

sudo apt-get install php8.2-fpm
sudo a2dismod php8.2
sudo a2enconf php8.2-fpm
sudo a2enmod proxy_fcgi
sudo a2dismod mpm_prefork
sudo a2enmod mpm_event
sudo a2enmod http2

sudo systemctl restart apache2

phpMyAdmin

The configuration file now needs a secret passphrase (blowfish_secret).

phpMyAdmin blowfish secret generator

In /usr/share/phpMyAdmin rename config.sample.inc.php to config.inc.php.  Use the link above to generate the line of code to add to this file. Change this line with the code that link gives you. 

$cfg[‘blowfish_secret’] = ”; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

The $cfg[‘TempDir’] (./tmp/) is not accessible

create tmp under /usr/share/phpMyAdmin.   I use chmod 755 and chown www-data:www-data so Apache can use it.  I am not a big fan of 777 for it.

 phpMyAdmin Homepage

I just upgraded to 5.1.1.  They recommended upgrading to 5 from 4.9.x LTS.  The phpmyadmin directory is /usr/share/phpmyadmin.  If you are installing new, create it first. You will go into it before running the commands below. 

sudo wget https://files.phpmyadmin.net/phpMyAdmin/5.1.1/phpMyAdmin-5.1.1-english.tar.gz sudo tar xvzf phpMyAdmin-5.1.1-english.tar.gz sudo cp -avr ./phpMyAdmin-5.1.1-english/. /usr/share/phpmyadmin

phpMyAdmin allows me a tool to create databases and users with ease.   I created a sa account and gave root limited access.   I moved phpMyAdmin off port 80 to another port.   It required a few basic steps of creating a Sites-Available file and removing the mods-enable configuration.  Both WP servers are now on this port.  

The main screen of phpMyAdmin shows you the databases on the left.  The versions of Apache, MySQL (MariaDB), and php on the right.  It also shows you the version of phpMyAdmin running.

I decided to setup a new database to parse out the Firewall Syslogs.  I created a new page for the Fortinet 60E hardening to show the results of this database.  pMyAdmin allows for the easy creation of databases, tables and setting up the user for the database.   Once you setup a unique table field, you can even edit, create and delete rows of data. 

In order for LOAD DATA LOCAL INFILE to work in your php code you need a few config file changes:

modify php.ini files in these directories.
/etc/php/7.4/apache2
/etc/php/7.4/cli
/etc/php/7.4/fpm

Under the [MySQLi] and [MySQL]

mysqli.allow_local_infile = On

mysql> SET GLOBAL local_infile = ‘ON’;
Query OK, 0 rows affected (0.00 sec)

mysql> SET GLOBAL local_infile = 1;
Query OK, 0 rows affected (0.00 sec)

SHOW GLOBAL VARIABLES LIKE ‘local_infile’;

Install mcrypt for php
https://computingforgeeks.com/install-php-mcrypt-extension-on-ubuntu/