How to Install GD Module for PHP in Linux Ubuntu 19.10 Operating System

Posted on


This is an article where the main content is about the installation of GD module for PHP. The installation itself exist and run in the Linux Ubuntu 19.10 operating system as an example. This module is fairly to put it simple, it is for basic image edit requirements. It will add or extend the PHP programming language support for basic image editing. There are two parts of the installation where each part of it focus on a different stressing. The first part is the preparation step. The other part is the actual process of the installation.

The Preparation Step of GD Module for PHP in Linux Ubuntu 19.10 Operating System

This is the first part of the installation which is the preparation step. There are several things which is important in order to install that module. Those preparation steps exist in the following steps below :

1. First of all, since it is an additional module for PHP programming language, just check the availability of the PHP installed in the operating system. So, execute the following command to search for it :

root@hostname:/etc/apache2/sites-available# apt list --installed | grep php 

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libapache2-mod-php7.3/eoan-updates,eoan-security,now 7.3.11-0ubuntu0.19.10.1 amd64 [installed,automatic]
libapache2-mod-php/eoan,eoan,now 2:7.3+69ubuntu2 all [installed]
php-common/eoan,eoan,now 2:69ubuntu2 all [installed,automatic]
php-mysql/eoan,eoan,now 2:7.3+69ubuntu2 all [installed]
php7.3-cli/eoan-updates,eoan-security,now 7.3.11-0ubuntu0.19.10.1 amd64 [installed,automatic]
php7.3-common/eoan-updates,eoan-security,now 7.3.11-0ubuntu0.19.10.1 amd64 [installed,automatic]
php7.3-json/eoan-updates,eoan-security,now 7.3.11-0ubuntu0.19.10.1 amd64 [installed,automatic]
php7.3-mysql/eoan-updates,eoan-security,now 7.3.11-0ubuntu0.19.10.1 amd64 [installed,automatic]
php7.3-opcache/eoan-updates,eoan-security,now 7.3.11-0ubuntu0.19.10.1 amd64 [installed,automatic]
php7.3-readline/eoan-updates,eoan-security,now 7.3.11-0ubuntu0.19.10.1 amd64 [installed,automatic]
php7.3/eoan-updates,eoan-updates,eoan-security,eoan-security,now 7.3.11-0ubuntu0.19.10.1 all [installed,automatic]
php/eoan,eoan,now 2:7.3+69ubuntu2 all [installed]

The above output is actually listing the available package where part of the package name containing the string of ‘php’. For more information about the tool usage, just access the article with the title of ‘List Installed Program in Ubuntu Linux using apt command’ in this link.

2. According to the output above, there is already an installed PHP programming language binary available in the operating system. The version of the PHP is 7.3. So, the next step is to search the GD module whether it is available for the installation or not. The name of the package or the module will be similar with the other installed PHP module. If the name is following the rule of the other PHP module name, the name will be ‘php7.3-gd’. If that so, just type and execute the following command in the command line interface to search it :

root@hostname:/etc/apache2/sites-available# apt-cache search php7.3-gd
php7.3-gd - GD module for PHP

The Actual Installation Step of GD Module for PHP in Linux Ubuntu 19.10 Operating System

In the previous part, the preparation part actually shows the output of the command execution. The output command execution actually try to list for the available PHP GD module installed in the operating system. According to the output, the package of php7.3-gd is available but it has not been installed in the operating system yet. So, just install the package as the following steps :

1. Apparently, the package exist but it is still not available as a package installed in the operating system. In order to install it, just execute the following command :

root@hostname:/etc/apache2/sites-available# apt-get -y install php7.3-gd
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 14 not upgraded.
Need to get 27,4 kB of archives.
After this operation, 142 kB of additional disk space will be used.
Get:1 eoan-updates/main amd64 php7.3-gd amd64 7.3.11-0ubuntu0.19.10.1 [27,4 kB]
Fetched 27,4 kB in 2s (15,7 kB/s)
Selecting previously unselected package php7.3-gd.
(Reading database ... 164067 files and directories currently installed.)
Preparing to unpack .../php7.3-gd_7.3.11-0ubuntu0.19.10.1_amd64.deb ...
Unpacking php7.3-gd (7.3.11-0ubuntu0.19.10.1) ...
Setting up php7.3-gd (7.3.11-0ubuntu0.19.10.1) ...
Creating config file /etc/php/7.3/mods-available/gd.ini with new version
Processing triggers for libapache2-mod-php7.3 (7.3.11-0ubuntu0.19.10.1) ...

2. Following the above step, just restart the Apache Webserver’s service to implement the changes in the form of a new package addition. Just execute the following command :

root@hostname:/etc/apache2/sites-available# systemctl restart apache2

Leave a Reply