How to List Modules Loaded or Enabled in PHP from command line

Updated on October 27, 2017

Question:

With the help of Webserver optimization guide, I was able to reduce the server load and improve website performance. But then PHP also loads lot of modules as extensions. I would like to know if there’s any command that will list all modules that are enabled with PHP? I’m using CentOS Linux and PHP 7.0

– Sara

Solution:

Yes, there’s a command to list all the modules loaded by PHP. Some of the modules would have come with PHP, and some you would have installed.

#php -m

apc
apcu
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd

...

...

Using pipe ( | ) and grep command, you can search for particular module.

php -m | grep gd

In the above example will grep module named gd.

Using phpinfo

It’s possible to list and view all PHP modules via phpinfo() function as well. To do that, create a PHP script with a call to phpinfo().

#vim info.php

Copy & paste the below code.

<?php

phpinfo();

?>

Browse info.php to view all the module information.

Warning

Leaving info.php or any script that uses phpinfo() function in the public HTML directory is vulnerable. You should remove such files or disable phpinfo in php.ini file.

Well, you will have to review all the modules loaded by Apache web server and remove unwanted ones to improve security.

Have an issue? Ask us and we’ll provide a solution.

Was this article helpful?

Related Articles

Leave a Comment