How to Install PHP 7.x in centOS 8

Add Remi Repository:

Remi, a third-party repository which offers multiple versions of PHP 7.x

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

Install the Remi repository by using the below command

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

Output:

[root@my ~]# yum install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm
Extra Packages for Enterprise Linux 8 - x86_64  954 kB/s | 3.4 MB     00:03
Last metadata expiration check: 0:00:01 ago on Sat 16 Nov 2019 02:47:09 PM EST.
remi-release-8.rpm                               18 kB/s |  20 kB     00:01
Dependencies resolved.
================================================================================
    Package            Arch         Version               Repository          Size
================================================================================
Installing:
    remi-release       noarch       8.0-4.el8.remi        @commandline        20 k
    Transaction Summary
================================================================================
Install  1 Package

List the available PHP module stream:

To check list the available PHP module by using following command

yum module list php

Output:

[root@my ~]# yum module list php
Remi's Modular repository for Enterprise Linux  155 kB/s | 509 kB     00:03
Safe Remi's RPM repository for Enterprise Linux 1.0 MB/s | 1.4 MB     00:01
CentOS-8 - AppStream
Name     Stream         Profiles                       Summary
php      7.2 [d][e]     common [d], devel, minimal     PHP scripting language

Remi's Modular repository for Enterprise Linux 8 - x86_64
Name     Stream         Profiles                       Summary
php      remi-7.2       common [d], devel, minimal     PHP scripting language
php      remi-7.3       common [d], devel, minimal     PHP scripting language
php      remi-7.4       common [d], devel, minimal     PHP scripting language

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
[root@my ~]#

Enable PHP : remi-7.4 module to install PHP 7.4:

NOTE: In this example we are installing PHP 7.4.

yum module enable php:remi-7.4 -y

Output:

[root@my ~]# yum module enable php:remi-7.4 -y
Last metadata expiration check: 0:04:16 ago on Thu 28 Nov 2020 02:49:58 PM EST.
Dependencies resolved.
================================================================================
    Package           Arch             Version             Repository         Size
================================================================================
Enabling module streams:
    php                                remi-7.4
    Transaction Summary
================================================================================
Complete!

Install PHP 7.4:

yum install -y php php-cli php-common

Check PHP Version:

Once you have installed PHP, check the PHP version

php -v

Output:

[root@vps ~]# php -v
PHP 7.4.6 (cli) (built: May 12 2020 08:09:15) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.6, Copyright (c), by Zend Technologies

This concludes our topic of installing php 7.4 on centOS 8 system.


CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!

1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month

Available Locations: LAX | MIA | ATL | FRA | AMS