How to List Installed PHP Modules on Ubuntu Linux

programming 3173456 640
programming 3173456 640

A few days ago, I upgraded from PHP 7.2 to PHP 7.3, and all related extensions were installed with PHP 7.2, supporting my WordPress websites and blogs. I wanted to upgrade only currently installed extensions that were in use with PHP 7.2.

If you are in a similar situation, refer to the steps below.

This brief tutorial shows students and new users how to list all compiled and installed PHP extensions on Ubuntu 16.04 | 18.04 and might also be workable on future Ubuntu versions. To list installed PHP extensions, follow the steps below:

List PHP Compiled Extensions

PHP / PHP-FPM has a list of all extensions that are compiled by default on Ubuntu. But not necessarily installed and in use. Extensions that are compiled with PHP installation are available to be used when necessary.

With a normal PHP install, not every library is compiled and installed — so if some functions are not working, you should look at what PHP extensions are compiled and installed.

So, to list compiled PHP / PHP-FPM extensions, run the commands below

php -m

That should show you something similar to the list below:

[PHP Modules]
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
igbinary
imagick
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
wddx
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

List PHP Installed Extension

Now, to find out what PHP / PHP-FPM extensions are installed, you run the commands below:

dpkg --get-selections | grep -i php

You should see a similar list below:

php                                             install
php-common                                      install
php-igbinary                                    install
php-imagick                                     install
php-redis                                       install
php7.2-cli                                      install
php7.2-common                                   install
php7.2-curl                                     install
php7.2-fpm                                      install
php7.2-gd                                       install
php7.2-json                                     install
php7.2-mbstring                                 install
php7.2-mysql                                    install
php7.2-opcache                                  install
php7.2-readline                                 install
php7.2-tidy                                     install
php7.2-xml                                      install
php7.2-xmlrpc                                   install
php7.2-zip                                      install

That’s how you know which extensions are installed

So if you only want to install PHP 7.3 extensions of what is currently installed with  PHP 7.2, use the commands above to list installed PHP extensions, then install those PHP 7.3 versions.

That’s it!

Congratulations! You have learned how to list PHP extensions to determine which are compiled and installed.

You may also like the post below:

Posted by
Richard W

I love computers; maybe way too much. What I learned I try to share at geekrewind.com.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: