Install and Manage PHP Packages on CentOS

This section provides a tutorial example on how to install PHP 7.2 on CentOS 8 systems using 'dnf/yum' as the package manager.

If you want to run PHP scripts on CentOS Linux systems, you can follow what I did on my CentOS 8 computer:

1. Login as "herong", who has admin privileges.

2. Run "dnf search" to find available PHP packages. I see "php" and some PHP modules available for installation:

herong$ dnf search php

php.x86_64 : PHP scripting language for creating dynamic web sites
php-common.x86_64 : Common files for PHP
php-fpm.x86_64 : PHP FastCGI Process Manager
php-dbg.x86_64 : The interactive PHP debugger
php-cli.x86_64 : Command-line interface for PHP
php-xml.x86_64 : A module for PHP applications which use XML
php-json.x86_64 : JavaScript Object Notation extension for PHP
...

3. Install the "php" package:

herong$ sudo dnf install php

 Package                      Architecture     Version
========================================================================
Installing:
 php                          x86_64           7.2.11-2.module_el8.1.0
Installing dependencies:
 apr                          x86_64           1.6.3-9.el8
 apr-util                     x86_64           1.6.1-6.el8
 centos-logos-httpd           noarch           80.5-2.el8
 httpd                        x86_64           2.4.37-16.module_el8.1.0
 httpd-filesystem             noarch           2.4.37-16.module_el8.1.0
 httpd-tools                  x86_64           2.4.37-16.module_el8.1.0
 mod_http2                    x86_64           1.11.3-3.module_el8.1.0
 nginx-filesystem             noarch           1:1.14.1-9.module_el8.0.0
 php-cli                      x86_64           7.2.11-2.module_el8.1.0
 php-common                   x86_64           7.2.11-2.module_el8.1.0
Installing weak dependencies:
 apr-util-bdb                 x86_64           1.6.1-6.el8
 apr-util-openssl             x86_64           1.6.1-6.el8
 php-fpm                      x86_64           7.2.11-2.module_el8.1.0
Enabling module streams:
 httpd                                         2.4
 nginx                                         1.14
 php                                           7.2

...
Installed:
  php-7.2.11-2.module_el8.1.0
  apr-util-bdb-1.6.1-6.el8.x86_64
  apr-util-openssl-1.6.1-6.el8.x86_64
  php-fpm-7.2.11-2.module_el8.1.0
  apr-1.6.3-9.el8.x86_64
  apr-util-1.6.1-6.el8.x86_64
  centos-logos-httpd-80.5-2.el8.noarch
  httpd-2.4.37-16.module_el8.1.0
  httpd-filesystem-2.4.37-16.module_el8.1.0
  httpd-tools-2.4.37-16.module_el8.1.0
  mod_http2-1.11.3-3.module_el8.1.0
  nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch
  php-cli-7.2.11-2.module_el8.1.0
  php-common-7.2.11-2.module_el8.1.0

Complete!

3. Verify the "php" package:

herong$ php -version

PHP 7.2.11 (cli) (built: Oct  9 2018 15:09:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

Cool! I have installed the "php" 7.2 package on my CentOS computer without any issues.

Table of Contents

 About This Book

 Introduction to Linux Systems

 Process Management

 Files and Directories

 Running Apache HTTP Server (httpd) on Linux Systems

 Running Apache Tomcat on Linux Systems

Running PHP Scripts on Linux Systems

Install and Manage PHP Packages on CentOS

 "php -i" - Dump PHP Environment Information

 Install and Manage PHP Modules on CentOS

 Files Used in PHP "include" Statements

 Publish PHP Scripts on Apache HTTP Server

 Dump PHP/Apache Environment Information

 Change PHP Configuration Settings

 Apache PHP file_put_contents() Permission Denied

 SELinux Security Context on /var/www/html

 Migrate Old Scripts to New PHP Release

 Running MySQL Database Server on Linux Systems

 Running Python Scripts on Linux Systems

 Conda - Environment and Package Manager

 GCC - C/C++ Compiler

 OpenJDK - Open-Source JDK

 Graphics Environments on Linux

 SquirrelMail - Webmail in PHP

 Tools and Utilities

 References

 Full Version in PDF/EPUB