Few days ago I decided to upgrade PHP 7.2 to PHP 7.3 and all related extensions that are installed with PHP 7.2 supporting my WordPress websites and blogs. I wanted to upgrade only currently installed extensions that were in use with PHP 7.2.
If you find yourself in similar situation, refer the steps below.
This brief tutorial shows students and new users how to list all compiled and installed PHP extensions on Ubuntu 16.04 | 18.04 and might also be workable on future Ubuntu versions.To list installed PHP extensions, follow the steps below:
Step 1: Listing PHP Compiled Extensions
PHP / PHP-FPM has a list of all extensions that are compiled by default on Ubuntu. but not necessarily installed and in use. Extensions that are compiled with PHP installation are available to be used when necessary.
With a normal PHP install, not every library is compiled and installed — so if some functions are not working, you should look at what PHP extensions are compiled and installed.
So, to list compiled PHP / PHP-FPM extensions, run the commands below
That should show you something similar to the list below:
[PHP Modules] calendar Core ctype curl date dom exif fileinfo filter ftp gd gettext hash iconv igbinary imagick json libxml mbstring mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql Phar posix readline redis Reflection session shmop SimpleXML sockets sodium SPL standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl Zend OPcache zip zlib [Zend Modules] Zend OPcache
Step 2: Listing PHP Installed Extension
Now, to find out what PHP / PHP-FPM extensions are installed, you run the commands below:
dpkg --get-selections | grep -i php
You should see similar list as below:
php install php-common install php-igbinary install php-imagick install php-redis install php7.2-cli install php7.2-common install php7.2-curl install php7.2-fpm install php7.2-gd install php7.2-json install php7.2-mbstring install php7.2-mysql install php7.2-opcache install php7.2-readline install php7.2-tidy install php7.2-xml install php7.2-xmlrpc install php7.2-zip install
That’s how you know which extensions are installed
So if you only want to install PHP 7.3 extensions of what currently installed with PHP 7.2, simply use the commands above to list installed PHP extension, then install those PHP 7.3 versions.
Congratulations! You have learned how to list PHP extensions to find out which are compiled and which are installed.
You may also like the post below: