How To Install PHP 7 on CentOS 7 / Redhat (RHEL) 7

Published: December 1, 2025 (Updated: Dec 1, 2025)

Enjoying this content? Subscribe to the Channel!

Essential Upgrade: How to Install PHP 7 on CentOS 7 and RHEL 7 (The Easy Way)


Why You Need PHP 7 on CentOS 7

Hi tech fans, and welcome back to Darren’s Tech Tutorials!

If you’re running a modern application stack on CentOS 7 or Red Hat 7 (RHEL 7), you’ve probably run into a frustrating issue: the default PHP version included with the distribution is often PHP 5. While reliable, PHP 5 is aging and lacks the performance and features required by today’s applications.

For example, newer frameworks and CMS platforms—like Drupal 8—simply won’t run on older versions. To ensure speed, security, and compatibility, we need to get PHP 7 installed.

Fortunately, it’s a quick and painless process. We just need to add a couple of trusted repositories, and you’ll be running PHP 7 in minutes!


Prerequisite: Setting Up Repositories

Before we can install PHP 7, we need to ensure our system can access the necessary packages. We will be using two essential repositories:

  1. EPEL (Extra Packages for Enterprise Linux): Required by Webtatic.
  2. Webtatic: This repository hosts the updated PHP 7 packages we need, as they are not available in the default YUM repositories.

Let’s jump right in. Remember, all commands should be run with sudo.

Step 1: Installing the EPEL Release Repository

First, install the EPEL repository package. This command fetches the EPEL setup file directly:

sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

If you see a message indicating the package is already installed, that’s perfectly fine. If it’s new, simply confirm the installation by pressing Y when prompted.

Step 2: Installing the Webtatic YUM Repository

Now that EPEL is configured, we can install the Webtatic repository. This is the source for our modern PHP 7 packages.

Copy and paste the following command into your terminal:

sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

Once this command completes successfully, your system is fully prepared to install the required PHP 7 packages.

Step 3: Installing PHP 7

With our repositories in place, we can now install the core PHP 7 package. For this tutorial, we are targeting PHP 7.0 (denoted by php70w).

Run the following YUM installation command:

sudo yum install php70w

YUM will now go out and fetch all the necessary dependencies for PHP 7. You will be prompted to confirm the installation and package sizes. Press Y to continue and complete the installation.

Step 4: Verifying the Installation

To confirm that PHP 7 has been successfully installed and is the correct active version on your system, run the version check command:

php -v

If everything worked correctly, you should see output similar to this (the specific patch version might vary):

PHP 7.0.25 (cli) (built: Feb 28 2022 10:45:00) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies

Success! You are now running a powerful, modern version of PHP.

Bonus Tip: Installing Additional PHP Extensions

When setting up a web application, you often need specific PHP extensions (like MySQL support, PDO, or GD for image manipulation).

Installing these extensions is easy once you have the php70w base installed. You simply use the same YUM install command structure, specifying the PHP version prefix (php70w-) followed by the package name.

For example, to install the crucial PDO package:

sudo yum install php70w-pdo

You can install multiple packages at once by listing them in the command line:

sudo yum install php70w-gd php70w-mysql

This ensures you can always tailor your PHP environment to meet the exact requirements of your applications.


Conclusion and Next Steps

That’s all there is to it! You’ve successfully upgraded your CentOS 7 or RHEL 7 server to run PHP 7, giving you the performance and compatibility necessary for modern web development.

If you encountered any issues or difficulties following along, please don’t hesitate to comment below—I’m always happy to help troubleshoot!

For more clear, accessible tech tutorials and sysadmin guides, make sure you subscribe to Darren’s Tech Tutorials.

Thanks for watching, and happy coding!