Here is a quick howto upgrade default PHP version provided on Fedora, RHEL or CentOS with latest version 7.4.
Repositories configuration:
On Fedora, standards repositories are enough, on Enterprise Linux (RHEL, CentOS) the Extra Packages for Enterprise Linux (EPEL) repository must be configured, and on RHEL the optional channel must be enabled.
Fedora 31
dnf install //rpms.remirepo.net/fedora/remi-release-31.rpmFedora 30
dnf install //rpms.remirepo.net/fedora/remi-release-30.rpmRHEL version 8.1
dnf install //dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm dnf install //rpms.remirepo.net/enterprise/remi-release-8.rpmRHEL version 7.7
wget //dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm wget //rpms.remirepo.net/enterprise/remi-release-7.rpm rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm subscription-manager repos --enable=rhel-7-server-optional-rpmsCentOS version 8.0
dnf install //dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm dnf install //rpms.remirepo.net/enterprise/remi-release-8.rpmCentOS version 7.7
wget //dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm wget //rpms.remirepo.net/enterprise/remi-release-7.rpm rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpmphp module usage
With Fedora modular and RHEL / CentOS 8, you can simply use the remi-7.4 stream of the php module
dnf module reset php dnf module install php:remi-7.4remi-php74 repository activation
Needed packages are in the remi-safe (enabled by default) and remi-php74 repositories, the latest is not enabled by default (administrator choice according to the desired PHP version).
RHEL or CentOS 7
yum install yum-utils yum-config-manager --enable remi-php74Fedora
dnf config-manager --set-enabled remi-php74PHP upgrade
By choice, the packages have the same name than in the distribution, so a simple update is enough:
yum updateThat's all :)
$ php -v PHP 7.4.0 (cli) (built: Nov 26 2019 20:13:36) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.0, Copyright (c), by Zend TechnologiesKnown issues
The upgrade can fail (by design) when some installed extensions are not yet compatible with PHP 7.4.
See the compatibility tracking list: PECL extensions RPM status
If these extensions are not mandatory, you can remove them before the upgrade, else, you will have to be patient.
Warning: some extensions are still under development, but it seems useful to provide them to allow upgrade to more people, and to allow user to give feedback to the authors.
More d'information
If you prefer to install PHP 7.4 beside default PHP version, this can be achieved using the php74 prefixed packages, see the PHP 7.4 as Software Collection post.
You can also try the configuration wizard.
The packages available in the repository was used as source for Fedora 32 (self contained change proposal, is already accepted and testable).
By providing a full feature PHP stack, with about 130 available extensions, 6 PHP versions, as base and SCL packages, for Fedora and Enterprise Linux, and with 200 000 download per day, remi repository became in the last 14 years a reference for PHP users on RPM based distributions, maintained by an active contributor to the projects (Fedora, PHP, PECL...).
See also:
- Posts RSS feed (versions announcements)
- Comments RSS feed
- Repository RSS feed (example for EL-8, php 7.4)
- Install PHP 7.3 on CentOS, RHEL or Fedora
- Install PHP 7.2 on CentOS, RHEL or Fedora
- Install PHP 7.1 on CentOS, RHEL or Fedora
PHP is a widely-used open-source programming language for web development created by Rasmus Lerdorf. It is an HTML-embedded scripting language for creating dynamic web sites.
CentOS 7/6 comes with PHP 5.x by default which is already the end of life.
In this post, we will see how to install PHP 7.4 / 7.3 / 7.2 on CentOS 7 / RHEL 7 & CentOS 6 / RHEL 6.
Add PHP 7.x Repository
Remi, a third-party repository which offers the latest version of PHP (7.4 / 7.3 / 7.2 / 7.1) for CentOS.
To enable the Remi repository, install the Remi repository auto-configuration package.
### CentOS 7 / RHEL 7 ### yum install -y //dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm yum install -y //rpms.remirepo.net/enterprise/remi-release-7.rpm ### CentOS 6 / RHEL 6 ### yum install -y //dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm yum install -y //rpms.remirepo.net/enterprise/remi-release-6.rpmInstall PHP 7.4 on CentOS 7
Use the below command to install PHP 7.4 package by temporarily enabling Remi PHP 7.4 repository.
Remi doesn’t provide PHP 7.4 packages for CentOS 6
yum install -y --enablerepo=remi-php74 php php-cliInstall PHP 7.3 on CentOS 7 & CentOS 6
Use the below command to install PHP 7.3 package by temporarily enabling Remi PHP 7.3 repository.
yum install -y --enablerepo=remi-php73 php php-cliInstall PHP 7.2 on CentOS 7 & CentOS 6
Use the below command to install PHP 7.2 package by temporarily enabling Remi PHP 7.2 repository.
yum install -y --enablerepo=remi-php72 php php-cliInstall PHP 7.1 on CentOS 7 & CentOS 6
Use the below command to install PHP 7.1 package by temporarily enabling Remi PHP 7.1 repository.
yum install -y --enablerepo=remi-php71 php php-cliCheck PHP Version
Once you have installed the required PHP version, check the PHP version with the following command.
Output:
PHP 7.4.1 (cli) (built: Dec 17 2019 16:35:58) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend TechnologiesInstall PHP Extensions
PHP extensions are compiled libraries which enables specific functions/support for your code. For example, installing PHP MySQL extension will enable your PHP code to connect with the MySQL database.
PHP extensions package is normally named like php-<extn_name>.
To install MySQL support, you can install php-mysqlnd package.
yum install -y --enablerepo=remi-php74 php-mysqlndOnce you have installed a particular extension, you can use the below command to verify it.
php -m | grep -i mysqlOutput:
mysqli mysqlnd pdo_mysqlPHP Extensions for WordPress
The following extensions are good enough to install and run WordPress on your CentOS system. WordPress recommends having PHP v7.3 for the installation.
yum install -y --enablerepo=remi-php73 php-dom php-simplexml php-ssh2 php-xml php-xmlreader php-curl php-date php-exif php-filter php-ftp php-gd php-hash php-iconv php-imagick php-json php-libxml php-mbstring php-mysqlnd php-openssl php-pcre php-posix php-sockets php-spl php-tokenizer php-zlibPHP Extensions for Joomla
The following extensions are good enough to install and run Joomla on your CentOS system. Joomla requires PHP v7.1 and above.
yum install -y --enablerepo=remi-php73 php-mysqlnd php-zlib php-xml php-pear php-json php-mcryptPHP Extensions for Drupal
The following extensions are good enough to install and run Joomla on your CentOS system. Drupal requires PHP v7.1 and above.
yum install -y --enablerepo=remi-php73 php-mysqlnd php-date php-dom php-filter php-gd php-hash php-json php-pcre php-pdo php-session php-simplexml php-spl php-tokenizer php-xmlConclusion
That’s All. Please share your feedback in the comments section.