PHP Extensions. Which ones?

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?

Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Site Moderator
Site Moderator badge
June 9, 2022

Hello there,

I just wanted to share this link if someone is looking into installing PHP 8.1 on the latest Ubuntu 22.04 LTS and also set up a local environment

As Bobby already mentioned, you could list all loaded PHP modules with the following command:

  1. php -m

You have installed PHP and verified the version you have running. You also installed any required PHP modules and were able to list the modules that you have loaded.


Bobby Iliev
Site Moderator
Site Moderator badge
May 11, 2022


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:



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



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