Hamsa K
7 min read | 3 years ago

How to Install PHP 7.4 on Centos 8

Install php 7.4 on centos 8

PHP is one of the most used server-side programming languages. Many popular CMS and frameworks such as WordPress, Magento, and Laravel are built in PHP. Recently PHP Version 7.4.0 has been released and developers are interested to use it in production. The official release date for GA was Nov 28, 2019.

Step 1: Add Epel and Remi repositories

we can install epel  and remi release through yum or dnf command

[root@centos ~]# yum install epel-release
[root@centos ~]# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
[root@centos ~]# yum install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

sample output:

[root@centos ~]# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
Last metadata expiration check: 0:05:01 ago on Wed 04 Dec 2019 04:49:11 PM IST.
epel-release-latest-8.noarch.rpm                                                                                                        9.2 kB/s |  21 kB     00:02
Dependencies resolved.
 Package                                    Arch                                 Version                               Repository                                  Size
 epel-release                               noarch                               8-7.el8                               @commandline                                21 k
Transaction Summary
Upgrade  1 Package
Total size: 21 k
Is this ok [y/N]:
[root@centos ~]# yum install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
Last metadata expiration check: 0:06:38 ago on Wed 04 Dec 2019 04:49:11 PM IST.
remi-release-8.rpm                                                                                                                      8.3 kB/s |  20 kB     00:02
Dependencies resolved.
 Package                                  Arch                               Version                                     Repository                                Size
 remi-release                             noarch                             8.0-4.el8.remi                              @commandline                              20 k
Transaction Summary
Install  1 Package
Total size: 20 k
Installed size: 14 k
Is this ok [y/N]: y

Step 2: List and enable php Module stream

Now we will check the list of available PHP module streams with following command.

[root@centos ~]# yum module list php
[root@centos ~]# yum module list php
Last metadata expiration check: 0:14:05 ago on Wed 04 Dec 2019 04:49:16 PM IST.
CentOS-8 - AppStream
Name                           Stream                                Profiles                                            Summary
php                            7.2 [d][x]                            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 [x]                          common [d], devel, minimal                          PHP scripting language
php                            remi-7.3 [x]                          common [d], devel, minimal                          PHP scripting language
php                            remi-7.4 [x]                          common [d], 

In this article we are going to install php 7.4 then we will enable the module stream as below

[root@centos ~]# yum  module enable php:remi-7.4
[root@centos ~]# yum  module enable php:remi-7.4
Last metadata expiration check: 0:18:26 ago on Wed 04 Dec 2019 04:49:16 PM IST.
Dependencies resolved.
 Package                                 Arch                                   Version                                   Repository                               Size
Enabling module streams:
 php                                                                            remi-7.4
Transaction Summary
Is this ok [y/N]: y

Step 3: Install php

Once php:remi-7.4 module ie enabled we can install php packages depends on your requirement.

[root@centos ~]# yum install php php-common php-cli php-gd php-xml php-pdo php-mysql php-mcrypt php-devel php-tidy
[root@centos ~]# yum install php php-common php-cli php-gd php-xml php-pdo php-mysql php-mcrypt php-devel php-tidy
Last metadata expiration check: 0:30:15 ago on Wed 04 Dec 2019 04:49:16 PM IST.
Dependencies resolved.
 Package                                    Arch                      Version                                                     Repository                       Size
 php                                        x86_64                    7.4.0-1.el8.remi                                            remi-modular                    3.0 M
 php-cli                                    x86_64                    7.4.0-1.el8.remi                                            remi-modular                    4.6 M
 php-common                                 x86_64                    7.4.0-1.el8.remi                                            remi-modular                    1.2 M
 php-devel                                  x86_64                    7.4.0-1.el8.remi                                            remi-modular                    1.1 M
 php-gd                                     x86_64                    7.4.0-1.el8.remi                                            remi-modular                     89 k
 php-pdo                                    x86_64                    7.4.0-1.el8.remi                                            remi-modular                    140 k
 php-pecl-mcrypt                            x86_64                    1.0.3-1.el8.remi.7.4                                        remi-modular                     35 k
 php-pecl-mysql                             x86_64                    1.0.0-0.23.20190415.d7643af.el8.remi.7.4                    remi-modular                     44 k
 php-tidy                                   x86_64                    7.4.0-1.el8.remi                                            remi-modular                     75 k
 php-xml                                    x86_64                    7.4.0-1.el8.remi                                            remi-modular                    213 k
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
 autoconf                                   noarch                    2.69-27.el8                                                 AppStream                       710 k
 automake                                   noarch                    1.16.1-6.el8                                                AppStream                       713 k
 centos-logos-httpd                         noarch                    80.5-2.el8                                                  AppStream                        24 k
 cmake-filesystem                           x86_64                    3.11.4-3.el8                                                AppStream                        40 k
 gd                                         x86_64                    2.2.5-6.el8                                                 AppStream                       144 k
 httpd                                      x86_64                    2.4.37-12.module_el8.0.0+185+5908b0db                       AppStream                       1.7 M
 httpd-filesystem                           noarch                    2.4.37-12.module_el8.0.0+185+5908b0db                       AppStream                        35 k
 httpd-tools                                x86_64                    2.4.37-12.module_el8.0.0+185+5908b0db                       AppStream                       102 k
 jbigkit-libs                               x86_64                    2.1-14.el8                                                  AppStream                        55 k
 libX11                                     x86_64                    1.6.7-1.el8                                                 AppStream                       612 k
 libX11-common                              noarch                    1.6.7-1.el8                                                 AppStream                       157 k
 libXau                                     x86_64                    1.0.8-13.el8                                                AppStream                        36 k
 libXpm                                     x86_64                    3.5.12-7.el8                                                AppStream                        58 k
 libjpeg-turbo                              x86_64                    1.5.3-7.el8                                                 AppStream                       155 k
 libtiff                                    x86_64                    4.0.9-13.el8                                                AppStream                       188 k
 libtool                                    x86_64                    2.4.6-25.el8                                                AppStream                       709 k
 libwebp                                    x86_64                    1.0.0-1.el8                                                 AppStream                       273 k
 libxcb                                     x86_64                    1.13-5.el8                                                  AppStream                       230 k
libxml2-devel                              x86_64                    2.9.7-5.el8                                                 AppStream                       1.0 M
 mod_http2                                  x86_64                    1.11.3-3.module_el8.0.0+185+5908b0db                        AppStream                       158 k
 oniguruma                                  x86_64                    6.8.2-1.el8                                                 AppStream                       188 k
 perl-Thread-Queue                          noarch                    3.13-1.el8                                                  AppStream                        24 k
 dejavu-fonts-common                        noarch                    2.35-6.el8                                                  BaseOS                           74 k
 dejavu-sans-fonts                          noarch                    2.35-6.el8                                                  BaseOS                          1.5 M
 emacs-filesystem                           noarch                    1:26.1-5.el8                                                BaseOS                           69 k
 fontconfig                                 x86_64                    2.13.1-3.el8                                                BaseOS                          275 k
 fontpackages-filesystem                    noarch                    1.44-22.el8                                                 BaseOS                           16 k
 keyutils-libs-devel                        x86_64                    1.5.10-6.el8                                                BaseOS                           48 k
 krb5-devel                                 x86_64                    1.16.1-22.el8                                               BaseOS                          546 k
 libcom_err-devel                           x86_64                    1.44.3-2.el8                                                BaseOS                           37 k
 libkadm5                                   x86_64                    1.16.1-22.el8                                               BaseOS                          184 k
 libselinux-devel                           x86_64                    2.8-6.el8                                                   BaseOS                          199 k
 libsepol-devel                             x86_64                    2.8-2.el8                                                   BaseOS                           85 k
 libverto-devel                             x86_64                    0.3.0-5.el8                                                 BaseOS                           18 k
 libxslt                                    x86_64                    1.1.32-3.el8                                                BaseOS                          249 k
 m4                                         x86_64                    1.4.18-7.el8                                                BaseOS                          223 k
 openssl-devel                              x86_64                    1:1.1.1-8.el8                                               BaseOS                          2.3 M
 pcre2-devel                                x86_64                    10.32-1.el8                                                 BaseOS                          605 k
 pcre2-utf16                                x86_64                    10.32-1.el8                                                 BaseOS                          228 k
 pcre2-utf32                                x86_64                    10.32-1.el8                                                 BaseOS                          220 k
 xz-devel                                   x86_64                    5.2.4-3.el8                                                 BaseOS                           62 k
 zlib-devel                                 x86_64                    1.2.11-10.el8                                               BaseOS                           56 k
 libmcrypt                                  x86_64                    2.5.8-26.el8                                                epel                            109 k
 libsodium                                  x86_64                    1.0.18-2.el8                                                epel                            162 k
 libtidy                                    x86_64                    5.6.0-5.el8                                                 epel                            227 k
 php-json                                   x86_64                    7.4.0-1.el8.remi                                            remi-modular                     73 k
 php-mysqlnd                                x86_64                    7.4.0-1.el8.remi                                            remi-modular                    255 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
 nginx-filesystem                           noarch                    1:1.14.1-9.module_el8.0.0+184+e34fea82                      AppStream                        24 k
 php-fpm                                    x86_64                    7.4.0-1.el8.remi                                            remi-modular                    1.6 M
 php-mbstring                               x86_64                    7.4.0-1.el8.remi                                            remi-modular                    523 k
 php-opcache                                x86_64                    7.4.0-1.el8.remi                                            remi-modular                    330 k
 php-sodium                                 x86_64                    7.4.0-1.el8.remi                                            remi-modular                     85 k
Transaction Summary
Install  66 Packages
Total download size: 28 M
Installed size: 110 M
Is this ok [y/N]:

once above packages are installed we can check version of php with following command.

[root@centos ~]# 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 Technologies

To view the list of installed modules run below command.

[root@centos ~]# php --modules


Warning! This site uses cookies
By continuing to browse the site, you are agreeing to our use of cookies. Read our terms and privacy policy