In this blog, we like the topic of servers and the multiple applications that we can install on it. Some of them are very professional and dedicated to a very specific user sector, but others are more common. Well, many of these server applications have a web environment, and the web is dominated by PHP. Now, how do we know which PHP modules are in our system? Well in this post, learn how to list the PHP modules installed on your system. So when you want to install other programs you know which modules are missing.
List the PHP modules installed on your system
This post, will list the modules installed either from the official repositories of your distribution or compiled manually. So you will be able to detail them all indistinctly as they were installed.
To do this, open a terminal and run the following command:
php -m
And there will be a screen output similar to this one:
[PHP modules]
.
.
.
ctype
date
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
.
.
.
We can combine this command with the grep command to filter the modules. For example, if we want to search exactly for mbstring, we can follow the following syntax
php -m | grep -i mbstring
mbstring
Remember that the -i option makes the search case insensitive.
Another way to do it
Linux is great because it allows you to do the same process in different ways. So, we can also use DNF and APT for that, depending on the distribution you use.
In the case of DNF which is the Fedora, CentOS, RHEL and derivatives package manager, open a terminal and run:
sudo dnf list installed | grep -i php
or using the RPM command:
rpm -qa | grep -i php
In case you use Debian, Ubuntu, Linux Mint or any derivative of these, then use dpkg in the following way:
dpkg --get-selections | grep -i php
Output:
.
.
.
php7.4-cli install
php7.4-common install
php7.4-fpm install
php7.4-gd
.
.
.
Similarly, you can combine this command with grep and perform filters.
So, this way you will know which are the PHP modules you have installed in your system
Conclusion
Thanks to this post, you can quickly find out which PHP modules you have in your system. This is very helpful in servers and also in computers where web applications are developed.