How to Install PHP 8 in CentOS 8

To add EPEL and REMI Repository.

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

To install yum utilities.

yum -y install yum-utils

To enable php 8 Remi repository.

yum module reset php

and

yum module install php:remi-8.0

Output:


Installing weak dependencies:
 nginx-filesystem
               noarch 1:1.14.1-9.module_el8.0.0+184+e34fea82 AppStream     24 k
Installing module profiles:
 php/common
Enabling module streams:
 httpd                2.4
 nginx                1.14
 php                  remi-8.0

Transaction Summary
================================================================================
Install  9 Packages

Total download size: 8.8 M
Installed size: 44 M
Is this ok [y/N]: y
.
.
.
.
Installed:
  httpd-filesystem-2.4.37-21.module_el8.2.0+494+1df74eae.noarch
  libxslt-1.1.32-4.el8.x86_64
  nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch
  oniguruma5php-6.9.6-1.el8.remi.x86_64
  php-cli-8.0.0-1.el8.remi.x86_64
  php-common-8.0.0-1.el8.remi.x86_64
  php-fpm-8.0.0-1.el8.remi.x86_64
  php-mbstring-8.0.0-1.el8.remi.x86_64
  php-xml-8.0.0-1.el8.remi.x86_64

Complete!

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.el8.remi                       remi-modular 1.6 M
Installing dependencies:
 apr           x86_64 1.6.3-9.el8                            AppStream    125 k
 apr-util      x86_64 1.6.1-6.el8                            AppStream    105 k
 centos-logos-httpd
               noarch 80.5-2.el8                             BaseOS        24 k
 httpd         x86_64 2.4.37-21.module_el8.2.0+494+1df74eae  AppStream    1.7 M
 httpd-tools   x86_64 2.4.37-21.module_el8.2.0+494+1df74eae  AppStream    103 k
 libsodium     x86_64 1.0.18-2.el8                           epel         162 k
 mailcap       noarch 2.1.48-3.el8                           BaseOS        39 k
 mod_http2     x86_64 1.11.3-3.module_el8.2.0+486+c01050f0.1 AppStream    156 k
Installing weak dependencies:
 apr-util-bdb  x86_64 1.6.1-6.el8                            AppStream     25 k
 apr-util-openssl
               x86_64 1.6.1-6.el8                            AppStream     27 k
 php-opcache   x86_64 8.0.0-1.el8.remi                       remi-modular 750 k
 php-pdo       x86_64 8.0.0-1.el8.remi                       remi-modular 152 k
 php-sodium    x86_64 8.0.0-1.el8.remi                       remi-modular  92 k

Transaction Summary
================================================================================
Install  14 Packages

Total download size: 4.9 M
Installed size: 14 M
Is this ok [y/N]: y
.
.
.
.

Installed:
  apr-1.6.3-9.el8.x86_64
  apr-util-1.6.1-6.el8.x86_64
  apr-util-bdb-1.6.1-6.el8.x86_64
  apr-util-openssl-1.6.1-6.el8.x86_64
  centos-logos-httpd-80.5-2.el8.noarch
  httpd-2.4.37-21.module_el8.2.0+494+1df74eae.x86_64
  httpd-tools-2.4.37-21.module_el8.2.0+494+1df74eae.x86_64
  libsodium-1.0.18-2.el8.x86_64
  mailcap-2.1.48-3.el8.noarch
  mod_http2-1.11.3-3.module_el8.2.0+486+c01050f0.1.x86_64
  php-8.0.0-1.el8.remi.x86_64
  php-opcache-8.0.0-1.el8.remi.x86_64
  php-pdo-8.0.0-1.el8.remi.x86_64
  php-sodium-8.0.0-1.el8.remi.x86_64

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
    with Zend OPcache v8.0.0, Copyright (c), by Zend Technologies

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