Hostwinds Tutorials

Search results for:


Table of Contents


Installing PHP Modules on CentOS 7
Search for PHP Modules
PHP Module Info
Installing a PHP Module
Installing Multiple PHP Modules
How To View Current PHP Modules
How To Remove A PHP Module

How to Install PHP Modules on CentOS 7

Tags: CentOS Web Panel 

Installing PHP Modules on CentOS 7
Search for PHP Modules
PHP Module Info
Installing a PHP Module
Installing Multiple PHP Modules
How To View Current PHP Modules
How To Remove A PHP Module

PHP modules, or extensions, can greatly extend the core functionality of PHP. These modules are compiled libraries that can help you implement different methods to connect to other services without the need to "reinvent the wheel." By enabling these modules, your PHP code can become more versatile and adaptable, allowing you to interact with things such as MySQL seamlessly. The focus of this article is to explain how you can enable these modules in a CentOS 7 server so that you can take your PHP code to the next level.

Prerequisites:

  • You must have already installed PHP on your CentOS 7 server. If you have not done this yet, please reference our tutorial: How to install PHP on CentOS 7.
  • You'll need to be logged in to your SSH. If you're not familiar with how to do this, take a moment and read through the following: Connecting to Your Server via SSH.

Installing PHP Modules on CentOS 7

Like any other installable software in CentOS 7, we'll be installing PHP modules using the "yum" package manager.

Search for PHP Modules

If you're not sure what PHP modules you'd like to install we can actually perform a search for different packages:

yum, search php-

This command will search for anything with "PHP-" in its name and display a list of available packages.

PHP Module Info

To know what all the different modules do you can use the yum info command:

yum info

For example, let's pretend that you want to know more about the PHP-CLI module, you'd issue the following:

yum info php-cli

This would generate output similar to the following:

Installed Packages
Name: PHP-CLI
Arch: x86_64
Version: 5.3.3
Release     : 48.el6_8
Size: 6.2 M
Repo: installed
From repo: updates
Summary: Command-line interface for PHP
URL: http://www.php.net/
License: PHP
Description: The PHP-CLI package contains the command-line interface
           : executing PHP scripts, /usr/bin/PHP, and the CGI interface.

Installing a PHP Module

As you can see from the above output, the test server we're using already has this module installed. However, if you needed to install it, you can do so via the following command:

yum install php-cli

Installing Multiple PHP Modules

You can, of course install multiple modules at once by using the following syntax:

yum install package-one package-two package-three

A practical example of this would be:

yum install php-cli php-fpm php php-punic

How To View Current PHP Modules

When logged into your server via SSH, type in the following command:

yum list installed *php*

This will populate a list, like the following, showing you all the current PHP modules installed.

Repository information has been removed from the above example

How To Remove A PHP Module

After installing any PHP module, you, of course, will have the opportunity to delete them.  To delete a PHP module, type the following command

yum remove php

You can remove multiple PHP modules by typing all the names you wish to remove, for example:

yum remove php

A list of PHP modules will be listed for removal, and typing these commands will require a [Y/N] (yes or no) response via a prompt to complete in the end.

Now your PHP modules chosen to be removed are uninstalled.

Like most things, moderation is the key, and it is best only to install modules that you need. I hope that after reading this article, you now feel more comfortable installing PHP modules. If you're interested in testing your server's PHP processing, we have an article that you might enjoy, which covers that: How To Create A PHP Info Page.

Written by Michael Brower  /  June 22, 2017