How to List Compiled and Installed PHP Modules in Linux

If you have installed a number of PHP extensions or modules on your Linux system and you trying to find out a particular PHP module has been installed or not, or you simply want to get a complete list of installed PHP extensions on your Linux system.

In this article, we will show you how to list all installed or compiled PHP modules from Linux command line.

How to List Compiled PHP Modules

The general command is php -m, which will show you a list of all “compiled” PHP modules.

# php -m
Listing Compiled PHP Modules
apc
bz2
calendar
Core
ctype
curl
date
dom
ereg
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
json
libxml
mbstring
mcrypt
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
sqlite3
standard
tidy
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
zip
zlib

You can search for a specific PHP module for instance php-ftp, using the grep command. Simply pipe the output from the above command to grep as shown (grep -i flag means ignore case distinctions, thus typing FTP instead of ftp should work).

# php -m | grep -i ftp

ftp

How to List Installed PHP Modules

To list all PHP modules that you have installed via a package manager, use the appropriate command below, for your distribution.

# yum list installed | grep -i php		#RHEL/CentOS
# dnf list installed | grep -i php		#Fedora 22+
# dpkg --get-selections | grep -i php		#Debian/Ubuntu
Listing Installed PHP Modules
php.x86_64                         5.3.3-49.el6                        @base    
php-cli.x86_64                     5.3.3-49.el6                        @base    
php-common.x86_64                  5.3.3-49.el6                        @base    
php-devel.x86_64                   5.3.3-49.el6                        @base    
php-gd.x86_64                      5.3.3-49.el6                        @base    
php-mbstring.x86_64                5.3.3-49.el6                        @base    
php-mcrypt.x86_64                  5.3.3-5.el6                         @epel    
php-mysql.x86_64                   5.3.3-49.el6                        @base    
php-pdo.x86_64                     5.3.3-49.el6                        @base    
php-pear.noarch                    1:1.9.4-5.el6                       @base    
php-pecl-memcache.x86_64           3.0.5-4.el6                         @base    
php-php-gettext.noarch             1.0.12-1.el6                        @epel    
php-tidy.x86_64                    5.3.3-49.el6                        @base    
php-xml.x86_64                     5.3.3-49.el6                        @base    

In case you want to find one particular module, like before, use a pipe and the grep command as shown.

# yum list installed | grep -i php-mbstring		#RHEL/CentOS
# dnf list installed | grep -i php-mbstring		#Fedora 22+
# dpkg --get-selections | grep -i php-mbstring	        #Debian/Ubuntu

To view all php command line options, run.

# php -h

You might also like to check out these following useful articles about PHP.

  1. 12 Useful PHP Commandline Tricks Every Linux User Should Know
  2. How to Use and Execute PHP Codes in Linux Command Line
  3. How to Install Different PHP Versions in Ubuntu
  4. How to Install OPCache to Speed Up Performance of PHP Apps

That’s all! In this article, we’ve explained how to list installed (or compiled in) modules in PHP. Use the comment form below to ask any questions.

Two small things before you go

If something didn’t work on your setup, leave a comment and tell me which distro and version you’re on. I read every one, and most of these articles got better because a reader pointed out what was missing.

And if it did work, share it. TecMint has stayed free for 14 years because people pass these articles around, and that traffic is what pays for writing the next one.

Leave a comment
Get two free Linux courses

Learn the Linux basics with two free courses and join 34,000+ readers getting practical TecMint tutorials and selected Pro TecMint articles every week.

Pro TecMint
Get lifetime access for $99

If you want to go beyond the free tutorials, Pro gives you 18 courses, 5 ebooks, and every future course I add. One payment, lifetime access, no renewals.

Aaron Kili
Aaron Kili
Contributor
About the author

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

4 Comments

Leave a Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.