How Can We Help?

How to install latest versions of PHP on CentOS

Table of Content
How to install latest version of php on centos

Since PHP 5.4 has achieved end of life, it is no longer being developed, although it is still available in the official CentOS 7 software repository.

To keep your CentOS 7 system up-to-date with the latest features and security patches, you need a newer version of PHP, which is usually the most recent version.

In this tutorial we will learn how to install the latest version of PHP on your CentOS machine. Currently the latest version of php is 8.1. Therefore, we will install the php8.1 on our machine.


  • Yum server configure on your centos machine
  • Super user or any normal user with SUDO privileges

Configuration before Installing of PHP versions

1. For PHP 7, use the following instructions to install and enable the EPEL and Remi repository on a CentOS 7 server.

#  yum install 
# yum install

2. The next step is to set up the yum-utils, a suite of applications designed to make working with yum repositories and packages easier. The included utilities essentially enhance the functionality of yum.

It may be used to manage yum repositories (by enabling or disabling them) and packages (by installing or removing them) without any human setup.

# yum install yum-utils

3. yum-config-manager, one of the utilities included in yum, may be set to utilise the Remi repository instead of the system repository when installing new versions of PHP.

Install latest PHP version

Before installing php 8.1 you need to enable the repository of that version to install it.

# yum-config-manager --enable remi-php81

The command below will install PHP 8.1 along with all required modules.

# yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo 

After installing your latest versions, you just need to enable it. To do so follow the below command

# systemctl start php-fpm 

How to check the PHP version

To check the running php version on your machine, there are two versions.

  1. Just run the below command
    # php -v 
  2. The second method is by using browser. To do so, just create a file called info.php on your default web server's directory with following content. For this tutorial I am using apache server.
    # echo '<?php phpinfo(); ?>' > /var/www/html/info.php 
    After this step, just go to your browser and search for http://server-ip/info.php.
latest php version
latest php version
Table of Contents