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

This is what I use to install PHP for WordPress.



This is how you activate your new PHP files.

sudo a2dismod php7.4 sudo a2enmod php8.0 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

sudo apt-get purge php5.6 php5.6-common php5.6-imagick php5.6-phpdbg sudo apt-get purge php7.0 php7.0-common php7.0-imagick php7.0-phpdbg sudo apt-get purge php7.1 php7.1-common php7.1-imagick php7.1-phpdbg sudo apt-get purge php7.2 php7.2-common php7.2-imagick php7.2-phpdbg sudo apt-get purge php7.3 php7.3-common php7.3-imagick php7.3-phpdbg

php 7.4 configuration

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

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

Prepping for php8.0


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

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

  1. First Install CURL by typing sudo apt-get install curl

  2. Then Restart Apache by typing sudo service apache2 restart

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

  4. will prompt to install… type y or yes!

  5. Then Restart Apache by typing sudo service apache2 restart

  6. 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.0/fpm/php.ini /etc/php/8.0/cli/php.ini /etc/php/8.0/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 php7.4-fpm
sudo a2enconf php8.0-fpm sudo apt purge libapache2-mod-php7.4 libapache2-mod-php sudo apt install libapache2-mod-php7.4 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 php7.4-fpm
sudo a2dismod php7.4
sudo a2enconf php8.0-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’;