Here, we will be showing you how to install PHP modules on your Ubuntu system as a post PHP install task to add features
Before you get started you need to have PHP installed on your Ubuntu system. If you haven’t you can start with this tutorial on how to install LAMP on Ubuntu 20.04. Once you are done with that tutorial, specifically the PHP install section then you can proceed with this tutorial
You may now proceed to set up the modules based on your application requirements. You can start by searching for PHP 7 modules in the apt package repository.
$ sudo apt-cache search php7*
The following is a partial output of what to expect.
Output
php7.4-bcmath - Bcmath module for PHP
php7.4-bz2 - bzip2 module for PHP
php7.4-cgi - server-side, HTML-embedded scripting language (CGI binary)
php7.4-cli - command-line interpreter for the PHP scripting language
php7.4-common - documentation, examples and common module for PHP
php7.4-curl - CURL module for PHP
php7.4-dba - DBA module for PHP
php7.4-dev - Files for PHP7.4 module development
...
php8.0-bz2 - bzip2 module for PHP
php8.0-cgi - server-side, HTML-embedded scripting language (CGI binary)
php8.0-cli - command-line interpreter for the PHP scripting language
php8.0-common - documentation, examples and common module for PHP
php8.0-curl - CURL module for PHP
php8.0-dba - DBA module for PHP
php8.0-dev - Files for PHP8.0 module development
php8.0-ds - PHP extension providing efficient data structures for PHP 7
php8.0-enchant - Enchant module for PHP
php8.0-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary)
php8.0-gd - GD module for PHP
You can now install the required PHP modules on your system as listed in the above command using the command in the format below.
$ sudo apt-get install php7.4-mysql php7.4-curl php7.4-json php7.4-bz2
There you have it! You are now ready to use PHP in your applications.
Next, you can follow this tutorial to learn how to enable and disable PHP modules on a version or SAPI basis on Ubuntu.
Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.