Upgrading from PHP 7.2 to PHP 7.4 with Red Hat Universal Base Image

Today, I noticed that the WordPress Admin Console was complaining that I was using PHP 7.2 which is getting old. I was kind of dreading upgrading because upgrades are a nightmare, but then I realized I had put everything in containers. One of the things that makes containers awesome is how easy it is to upgrade software once you have everything blueprinted with container image builds. While it took a lot of work to get all of my services into containers (see also: A Hacker’s Guide To Moving Linux Services Into Containers).

Here’s what I did to upgrade from PHP 7.2 to PHP 7.4 with Red Hat Universal Base Image at a high level:

  1. Rebuilt the PHP container
  2. Killed my internal MediaWiki instance to test the new version (systemd restarted the container perfectly)
  3. Killed my WordPress instance (systemd restarted the container perfectly)
  4. Clicked on a page in the WordPress Admin page and noticed that it was much faster

 

Going one layer deeper, here’s what I did. First, I added a new line to my Containerfile:

Then, I added the following line right before my YUM install command. This highlights the magic of Application Streams in RHEL. It’s super easy to go from PHP 7.2, the default installed on RHEL, to PHP 7.4 which is packaged as a module in RHEL 8:

The total Container file ended up looking like this:

Next, I rebuilt the image:

When the build completed, I killed my private MediaWiki instance to test. If the MediaWiki instance would have failed, I would have troubleshooted before killing my public site:

I tested it in a browser:

It worked like a charm, so I got brave enough to kill my public WordPress instance:

Then I tested it:

Final step, commit the change to git:

That’s it. Now my rebuilds will always happen with PHP 7.4. When an Application Stream Comes out for PHP 7.5+ I’ll just perform this same process but bump the number. So easy, so nice. The stability of the RHEL userspace combined with the convenience of containers makes this upgrade painless.

Leave a Reply

Your email address will not be published.