How to upgrade to PHP 8 on CentOS 7

In this tutorial I will show you how to upgrade to PHP version 8 on CentOS 7. Having the latest stable PHP 8 will fix many older vulnerabilities. Lets follow these quick steps below to upgrade your PHP version.

Before moving forward make sure to have a backup image of your server.

  1. Open your console windows and connect to your server.
  2. Lets start by disabling all the old PHP versions.
yum-config-manager --disable remi-php56
yum-config-manager --disable remi-php70
yum-config-manager --disable remi-php71
yum-config-manager --disable remi-php72
yum-config-manager --disable remi-php73
yum-config-manager --disable remi-php74

3. Lets run the following commands individually to download the PHP 8 packages we need.

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-8.rpm
rpm -Uvh remi-release-8.rpm epel-release-latest-8.noarch.rpm

4. We will now run the commands to install the latest PHP version 8 software.

yum install yum-utils
yum-config-manager --enable remi-php80
yum update -y

5. You should now be on the latest version of PHP 8. You can check your version by typing in php -v in the console window.

6. Update all your websites and or applications to use the latest PHP build you installed.

I hope this article was helpful, if you have any questions, please feel free to contact me. If you would like to be notified of when I create a new post, you can subscribe to my blog alert.


Discover more from Patrick Domingues

Subscribe to get the latest posts sent to your email.

author avatar
Patrick Domingues

10 Comments

  1. thanks for the post. the update was successful, but php codes appear on my page, they are not interpreted, what can I do?

    1. Hello, thank you for stopping by. What do you mean PHP code appear on your page? When you load the website you see a string of PHP loading with the content? Can you provide the full string that it is showing?

  2. Did not work. All commands seemed to run successfully, no errors, but the final php -v still shows PHP 5.4.16.

    1. Hello Barry, I did not account for all the older php versions. Did you yum-config-manager --disable remi-php 54 ? I think that would be the version that you have mentioned. Also doesn’t hurt to throw a reboot at it.

  3. on the rpm command I got:
    error: Failed dependencies:
    (redhat-release >= 8.8 or centos-stream-release >= 8) is needed by remi-release-8.8-1.el8.remi.noarch
    rpmlib(RichDependencies) = 8 is needed by epel-release-8-19.el8.noarch

    1. The error message you received is indicating that there are missing dependencies when you’re trying to use the `rpm` command. Here’s a breakdown of what it means:

      1. `(redhat-release >= 8.8 or centos-stream-release >= 8) is needed by remi-release-8.8-1.el8.remi.noarch`: This part of the error message is telling you that the package `remi-release-8.8-1.el8.remi.noarch` requires either `redhat-release` version 8.8 or higher or `centos-stream-release` version 8 or higher to be installed on your system. It seems that your system currently has an older version of these packages.

      2. `rpmlib(RichDependencies) = 8 is needed by epel-release-8-19.el8.noarch`: This part of the error message is telling you that the package `epel-release-8-19.el8.noarch` requires a specific version of `rpmlib` (RichDependencies), which is version 8. Your system might have an older version of `rpmlib` installed.

      To resolve these dependency issues, you can try the following steps:

      1. Update your system: Make sure your system is up to date by running the following commands, which will update all packages:
      sudo yum update
      or
      sudo dnf update

      The command to use depends on whether you’re using CentOS or Red Hat.

      2. After updating your system, try installing the packages again using the `rpm` command or any package manager you prefer.

      3. If you’re still facing dependency issues, you may need to manually download and install the required packages mentioned in the error message. You can usually find these packages on the official CentOS or Red Hat repositories. Use the package manager (either `yum` or `dnf`) to install them.

      For example:
      sudo yum install redhat-release
      or
      sudo dnf install redhat-release

      Repeat this process for any other missing dependencies mentioned in the error message.
      After following these steps, you should be able to install the desired packages without encountering dependency issues.

  4. Hi its awesome i upgraded the php version from 7.2 to 8 and its 8 now in instance but when I visit WordPress dashboard its still saying PHP version 7.2 why is that? can you please suggest me how to solve this one? please check the below screenshots

Leave a Comment

Stay Informed

Receive instant notifications when new content is released.