Question

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

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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

https://www.digitalocean.com/community/tutorials/how-to-install-php-8-1-and-set-up-a-local-development-environment-on-ubuntu-22-04

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.

Regards

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