---
# Upgrading from PHP 7.2 to PHP 7.4 with Red Hat Universal Base Image
**URL:** https://crunchtools.com/upgrading-from-php-7-2-to-php-7-4-with-red-hat-universal-base-image/
Date: 2021-10-15
Author: admin
Post Type: post
Summary: 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 toContinue Reading "Upgrading from PHP 7.2 to PHP 7.4 with Red Hat Universal Base Image" →
Categories: Articles
Tags: Best Practices, Container Images, RHEL, Systems Administration
---
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](http://crunchtools.com/moving-linux-services-to-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:
- Rebuilt the PHP container
- Killed my internal MediaWiki instance to test the new version (systemd restarted the container perfectly)
- Killed my Wordpress instance (systemd restarted the container perfectly)
- 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:
```
vim Containerfile-httpd-php
```
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:
```
RUN yum module enable -y php:7.4
```
The total Container file ended up looking like this:
```
FROM registry.access.redhat.com/ubi8/ubi-init
MAINTAINER fatherlinux <[email protected]>
RUN yum module enable -y php:7.4
RUN yum install -y mariadb-server mariadb php php-apcu php-intl php-mbstring php-xml php-json php-mysqlnd crontabs cronie iputils net-tools;yum clean all
RUN systemctl enable mariadb
RUN systemctl enable httpd
RUN systemctl disable systemd-update-utmp.service
ENTRYPOINT ["/sbin/init"]
CMD ["/sbin/init"]
```
Next, I rebuilt the image:
```
podman build -f Containerfile-httpd-php -t localhost/httpd-php
```
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:
```
podman kill learn.fatherlinux.com
```
I tested it in a browser:
```
https://learn.fatherlinux.com
```
It worked like a charm, so I got brave enough to kill my public Wordpress instance:
```
podman kill wordpress.crunchtools.com
```
Then I tested it:
```
https://crunchtools.com
```
Final step, commit the change to git:
```
git commit Containerfile-httpd-php
git push
```
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.
---
## Categories
- Articles
---
## Navigation
- [Home](https://crunchtools.com/)
- [Articles](https://crunchtools.com/category/articles/)
- [Events](https://crunchtools.com/category/events/)
- [News](https://crunchtools.com/category/news/)
- [Presentations](https://crunchtools.com/category/presentations/)
- [Software](https://crunchtools.com/software/)
- [Beaver Backup](https://crunchtools.com/software/beaver-backup/)
- [Check BGP Neighbors](https://crunchtools.com/software/check-bgp-neighbors-nagios/)
- [Chev](https://crunchtools.com/software/chev-check-vulnerabilities-script/)
- [Graph BGP Neighbors](https://crunchtools.com/software/grpah-bgp-neighbors/)
- [Graph MySQL Stats](https://crunchtools.com/software/graph-mysql-stats/)
- [Graph Sockets Pipes Files](https://crunchtools.com/software/graph-sockets-pipes-files/)
- [MCP Servers](https://crunchtools.com/software/mcp-servers/)
- [Petit](https://crunchtools.com/software/petit/)
- [Racecar](https://crunchtools.com/software/racecar/)
- [Shiva](https://crunchtools.com/software/shiva/)
- [About](https://crunchtools.com/about/)
- [Home](https://crunchtools.com)
## Tags
- Best Practices
- Container Images
- RHEL
- Systems Administration