Current Location: Home> Latest Articles> Complete Guide to Upgrading PHP on CentOS

Complete Guide to Upgrading PHP on CentOS

M66 2025-10-16

Steps to Upgrade PHP on CentOS

Upgrading PHP on CentOS is a common task that involves configuring repositories, installing PHP, and managing extensions. Below are the detailed steps:

Enable Remi Repository

sudo yum install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

Install EPEL Repository

sudo yum install https://dl.fedoraproject.org/pub/epel/8/x86_64/e/epel-release-8-8.noarch.rpm

Install the Latest PHP Version

sudo yum update
sudo yum install php7.x

Configure PHP Version

sudo alternatives --set php /usr/bin/php7.x

Enable Extensions

sudo yum install php-extension-module-list
sudo yum install php-extension-module-name

Verify Installation

php -v

Other Considerations

  • Choose the appropriate PHP version based on application compatibility.
  • If other PHP versions are installed, use alternatives --config php to switch between them.
  • When installing extensions, replace php-extension-module-list and php-extension-module-name with the desired extensions.
  • After upgrading PHP, you may need to restart the web server, such as Apache or Nginx, to apply changes.

The above guide provides a complete process for upgrading PHP on CentOS, helping system administrators and developers update PHP smoothly.