Question

PHP Extensions. Which ones?

  • Posted May 10, 2022
  • PHP

I wanted to know which PHP extensions I have installed. How do I query that? how do I install specific extensions, once I find out if the ones I need for an installation are missing?

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello,

In addition to what has been mentioned already, another way of doing this is using the following command:

php -m

This will show you all of the loaded PHP modules.

Alternatively, you can also create a PHP info file, called info.php for example, with the following content:

<?php

phpinfo();

Then if you were to visit the file via your browser you will see all of the needed PHP configurations on your server.

Best,

Bobby

Ey @aecsp2000,

You can check for the package versions installed on the system to get the PHP version:

$ sudo apt list --installed | grep php

PHP extensions are compiled libraries that extend the core functionality of PHP. Extensions are available as packages and can be easily installed with apt.

$ sudo apt install php-[extname]

For example, to install MySQL and GD extensions, you would run the following command:

$ sudo apt install php-mysql php-gd

After installing a new PHP extension, depending on your setup, do not forget to restart Apache or PHP FPM service.

Hope that helps,

Sergio Turpín