∟Install and Manage PHP Modules on CentOS

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

If you are developing a Web application using PHP scripts, you may need to install additional PHP modules as shown in this tutorial.

1. Install php-json package, if you see the "Call to undefined function json_decode()" error:

herong$ test-script.php
Call to undefined function json_decode()

herong$ sudo yum search php | grep json
php-json.x86_64 : JavaScript Object Notation extension for PHP
...

herong$ sudo dnf install php-json
...
Installed:
  php-json-7.2.11-2.module_el8.1.0+209+03b9a8ff.x86_64

2. Install php-mbstring package, if you see the "Call to undefined function mb_internal_encoding()" error:

herong$ test-script.php
Call to undefined function mb_internal_encoding()

herong$ sudo yum search php | grep mb
php-embedded.x86_64 : PHP library for embedding in applications
php-mbstring.x86_64 : A module for PHP applications which need
   multi-byte string

herong$ sudo dnf install php-mbstring
...
Installed:
  php-mbstring-7.2.11-2.module_el8.1.0+209+03b9a8ff.x86_64

3. Install php-mysqlnd package, if you see the "Call to undefined function mysqli_connect()" error:

herong$ test-script.php
Call to undefined function mysqli_connect

herong$ sudo yum search php | grep mysql
php-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases

herong$ sudo dnf install php-mysqlnd
...
Installed:
  php-mysqlnd-7.2.11-2.module_el8.1.0+209+03b9a8ff.x86_64
  php-pdo-7.2.11-2.module_el8.1.0+209+03b9a8ff.x86_64

4. Install php-mysqlnd package, if you see the "Call to undefined function mysqli_connect()" error:

herong$ test-script.php
Uncaught Error: Class 'ZipArchive' not found...

herong$ sudo yum search php | grep zip
php-pecl-zip.x86_64 : A ZIP archive management extension

herong$ sudo dnf install php-pecl-zip
...
Installed:
  libzip-1.5.1-2.module_el8.2.0+313+b04d0a66.x86_64
  php-pecl-zip-1.15.3-1.module_el8.2.0+313+b04d0a66.x86_64

If you see more errors on undefined functions, you can continue to search and install additional PHP modules with the "dnf/yum" command.

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