Share your love
How To Upgrade PHP Version on CentOS 7

In this guide from the Orcacore website, you will learn How To Upgrade PHP Version on CentOS 7. PHP (Hypertext Preprocessor) is known as a general-purpose scripting language that can be used to develop dynamic and interactive websites. It was among the first server-side languages that could be embedded into HTML, making it easier to add functionality to web pages without needing to call external files for data. Its use has evolved over the years, with regular upgrades adding features and unlocking new capabilities.
Table of Contents
Steps To Upgrade PHP Version on CentOS 7
To complete this guide, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide on the Initial Server Setup with CentOS 7.
1. Check Default CentOS 7 PHP Version
The default PHP version on CentOS 7 is 5.4. To verify your current PHP version, run the command below:
php -v
At this point, in your output, you should see:

2. Install PHP Remi Repository on CentOS 7
To upgrade your PHP version, you must install the Remi repository on your server. Remi’s RPM repository is a free and stable YUM repository mainly for the PHP stack.
To do this, run the command below:
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
At this point, use the following command to install the yum-utils package:
yum-utils is a collection of tools and programs for managing yum repositories, installing debug packages, source packages, extended information from repositories, and administration.
sudo yum install yum-utils -y
3. Enable PHP Remi Repo on CentOS 7
Next, you need to enable Remi for the latest version of PHP on CentOS 7 with the following command:
sudo yum-config-manager --enable remi-php81
Run the command below to see if the Remi repository for PHP 8.1 is enabled on your server:
sudo yum repolist
You should get the following output:

Note: If you want to install PHP 7.1, PHP 7.2, PHP 7.3, PHP 7.4, or PHP 8.0 on CentOS 7, just enable it as below:
# yum-config-manager --enable remi-php71
# yum-config-manager --enable remi-php72
# yum-config-manager --enable remi-php73
# yum-config-manager --enable remi-php74
# yum-config-manager --enable remi-php8.0
Then, update your local package index:
sudo yum update -y
Check your PHP version again:
php -v
Output
PHP 8.1.10 (cli) (built: Aug 30 2022 16:09:36) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.10, Copyright (c) Zend Technologies
As you can see, PHP has been upgraded to the latest version.
Conclusion
At this point, you have learned to upgrade the PHP Version on CentOS 7. Upgrading PHP on CentOS 7 improves security, performance, and compatibility with modern applications. Older versions no longer receive updates, leaving systems vulnerable.
Hope you enjoy it. Please subscribe to us on Facebook and YouTube.
Also, you may like these articles:
How To Install Django on CentOS 7
Set up Siege Stress Tester on CentOS 7