How to Install PHP 8 in CentOS 7

To add EPEL and REMI Repository.

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm

To install yum utilities.

yum -y install yum-utils

To enable php 8 Remi repository.

yum-config-manager --disable 'remi-php*'
yum-config-manager --enable   remi-php80

To install any remaining updates.

yum update

TO Install PHP 8

To install PHP.

yum install php

Output:

Dependencies Resolved

================================================================================
 Package          Arch        Version                     Repository       Size
================================================================================
Installing:
 php              x86_64      8.0.0-1.el7.remi            remi-php80      1.7 M
Installing for dependencies:
 apr              x86_64      1.4.8-7.el7                 base            104 k
 apr-util         x86_64      1.5.2-6.el7                 base             92 k
 httpd            x86_64      2.4.6-97.el7.centos         updates         2.7 M
 httpd-tools      x86_64      2.4.6-97.el7.centos         updates          93 k
 libsodium        x86_64      1.0.18-1.el7                epel            147 k
 mailcap          noarch      2.1.41-2.el7                base             31 k
 php-cli          x86_64      8.0.0-1.el7.remi            remi-php80      5.3 M
 php-common       x86_64      8.0.0-1.el7.remi            remi-php80      1.2 M
 php-sodium       x86_64      8.0.0-1.el7.remi            remi-php80       86 k

Transaction Summary
================================================================================
Install  1 Package (+9 Dependent packages)

Total download size: 11 M
Installed size: 49 M
Is this ok [y/d/N]: y
.
.
.
.
Installed:
  php.x86_64 0:8.0.0-1.el7.remi

Dependency Installed:
  apr.x86_64 0:1.4.8-7.el7             apr-util.x86_64 0:1.5.2-6.el7
  httpd.x86_64 0:2.4.6-97.el7.centos   httpd-tools.x86_64 0:2.4.6-97.el7.centos
  libsodium.x86_64 0:1.0.18-1.el7      mailcap.noarch 0:2.1.41-2.el7
  php-cli.x86_64 0:8.0.0-1.el7.remi    php-common.x86_64 0:8.0.0-1.el7.remi
  php-sodium.x86_64 0:8.0.0-1.el7.remi

Complete!

NOTE: It will prompt for permission type y and press Enter to proceed with the installation.

Check PHP Version.

php -v

Output:

[root@vps ~]# php -v
PHP 8.0.0 (cli) (built: Nov 24 2020 17:04:03) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies

This concludes our topic of installing PHP 8 on the CentOS 7 system.