Open In App

How to Install PHP Extension in Ubuntu?

PHP extensions are compiled libraries that allow you to use special functions in your PHP code. PHP extensions can be compiled statically in PHP or dynamically loaded at the time of execution. By using extensions, you can prevent the need to recreate the same code for many applications. To use an extension, all you need to do is connect it to the PHP binary of your application. You can use publicly available PHP extensions or create your own:  

Verify PHP extension installation on Ubuntu

Open the terminal on your Ubuntu system and type the following command to check whether your extension is installed or not.



dpkg –list | grep <extension-name> 

Replace <extension-name> with your actual extension name. For example :- dpkg –list | grep php-intl



If there is no result like shown in the above image, then follow the steps below to install your PHP extension.

Installation of PHP extension in Ubuntu

To install the PHP extension in Ubuntu follows the following steps:

Step 1: Update your system packages using the following command:

sudo apt-get update -y

Step 2: Run the following command for installing your PHP extension:

sudo apt-get install -y <php-extension>

Here, replace <extension-name> with your actual extension name. For example:- sudo apt-get install -y php-intl

Now again verify the installation of the PHP extension using the following command:

dpkg –list | grep <extension-name> 

So this is how we can install PHP extension in Ubuntu.

Article Tags :