Report this

What is the reason for this report?

PHP Extensions. Which ones?

Posted on May 10, 2022

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?



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!

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.

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

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

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.