Web Development

How To Upgrade PHP On Enterprise Linux

Hypertext Preprocessor, or PHP is a general purpose, server side scripting language that is often embedded in HTML. This enables a server to generate HTML and send the code back to the client, which means the user can then interact with the page. Pretty nifty right? That’s how you are able to interact with this website!

PHP 8 End Of Life

Like all software, PHP has a steady development cycle that enables new features, bugs, and security issues to be resolved. On November 26, 2023, PHP version 8.0 will become end of life. This means newer software can potentially break and security issues will no longer be patched.

Potential Risk

It’s best practice to upgrade to the latest version if the front end software on the server supports doing so. This unfortunately comes with a bit of risk as front end software may not support the current version. I’d recommend taking the time to research if the current version is supported or talk with your software vendor to ascertain if the current version is supported.

In this example, this website runs the latest version of WordPress, so proceeding with the upgrade is fairly low risk. I have snapshot the virtual machine in advanced just in case. This type of stuff always makes my skin crawl, and you can never be too careful!

How To Upgrade PHP On Enterprise Linux

Enterprise Linux includes those running Red Hat, Rocky, Alma, or Oracle Linux. It is fairly straightforward to upgrade to the latest version and can be done with a couple of commands. In this exercise we will add the Remi Repository, and enable the PHP module to upgrade from it, rather than the default system repos. Remi Repo is a free and stable YUM repository mainly for the PHP stack. It contains packages for the latest versions of PHP.

With several explanations out of the way, here’s how you do it:

\\ Add the Remi Repo to Enterprise Linux 8.x
sudo dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

or

\\ Add the Remi Repo to Enterprise Linux 9.x
sudo dnf -y install https://rpms.remirepo.net/enterprise/remi-release-9.rpm

\\ For either, then:

\\ Upgrade PHP
dnf module reset php
dnf module enable php:remi-8.3
dnf update php\*

\\ You may also want to reboot
sudo reboot

\\ Check the PHP version
php -v
The command php -v ran on RHEL 8.
The command php -v ran on RHEL 8. Success!

Conclusion

In this tutorial I have demonstrated how to upgrade from PHP 8.0 to 8.3 on Enterprise Linux. If you have any questions, comments, or concerns, feel free to comment below or visit us at our forum. Happy hacking!

sysadminafterdark

Just another bastard operator from hell empowering others to deliver self-hosted solutions one night at a time. Sysadmin by day, homelab by night.

Start the discussion at forum.sysadminafterdark.com

Back to top button