How to List Compiled PHP Modules from Command Line

Posted on by Alex Gorzen | Updated:
Reading Time: 2 minutes
Pre-Flight Check
  • These instructions are intended specifically for listing the existing compiled PHP modules from the command line.
  • Your server environment may be different, but we will go over several options that you might run into. We'll be using an Ubuntu Server with only a single PHP version on it, and two CentOS 7 servers, one with cPanel and one with InterWorx.
How to List Compiled PHP Modules from Command Line

Single PHP Version

If your server only has a single PHP version installed, you can run this PHP command anywhere, and it will give you the same list of modules. The general command we will be using is php -m. This command will give you the full list of installed PHP modules/extensions.

root@host [~]# php -m

This command will give you an output similar to the following information.

bcmath
bz2
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
hash
iconv
imagick
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
zip
zlib

[Zend Modules]

If you're looking for one particular item from the list, we can use a pipe with the grep command like so.

root@host [~]# php -m | grep -i reflection
Reflection
root@host [~]#

In the case above, we "grep'd" the list of existing PHP modules searching specifically for the PHP module "reflection". To search for a module on your server, simply replace the "reflection" module name with the name of the module you're searching for! A full list of available PHP modules can be found here: https://www.php.net/manual/en/extensions.alphabetical.php

The command above will only display the modules with the word “reflection” in it, and the "-i" flag denotes that our search term will be case-insensitive. So, replacing the word "reflection" with whatever module or search term you are trying to find should be easy to do.

Multiple PHP Versions

If your server has multiple PHP versions installed, like on a newer cPanel or InterWorx server, you may have different PHP modules for each PHP version. You can check which modules are available for the different versions by calling the different PHP versions directly.

On one of Liquid Web's Fully Managed cPanel servers running CentOS 7, the full path would be as follows.

root@host [~]# /opt/cpanel/ea-php73/root/usr/bin/php-cgi

So, if I run that command with the -m flag, it then provides us will all the modules specifically for PHP 7.3. If you switch the path to ea-php72 or 56, then it would give the modules for that PHP version.

root@host [~]# /opt/cpanel/ea-php73/root/usr/bin/php-cgi -m
[PHP Modules]
bcmath
bz2
cgi-fcgi
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
hash
iconv
imagick
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
zip
zlib

[Zend Modules]

root@host [~]# 

On a Fully Managed InterWorx server, the full path would be as follows.

root@host [~]# /opt/remi/php73/root/usr/bin/php-cgi

Or, you can use the built-in shortcut commands.

root@host [~]# php73 -m

root@host [~]# php56 -m

root@host [~]# php54 -m
Avatar for Alex Gorzen

About the Author: Alex Gorzen

Alex Gorzen has been helping others with technology his whole life. He played with computers even before he could read and wants to make sure his children share that same love as they grow up. In his free time, he enjoys gardening, building things, and learning new skills.

Latest Articles

Change cPanel password from WebHost Manager (WHM)

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change the root password in WebHost Manager (WHM)

Read Article