In this tutorial, we will look at how to install the GD image processing library for PHP5 on Ubuntu Linux. The GD library is a very popular module which allows dynamic image processing from within PHP.
The process for installing GD for use with PHP5 on Ubuntu outlined below works for Ubuntu 10.04, Ubuntu 10.10, Ubuntu 11.04, Ubuntu 11.10, Ubuntu 12.04, and on Debian as well.
To install the GD library, run the following command with superuser privileges:
apt-get install php5-gd
After the library has been installed, we need to restart the Apache web server for the changes to take effect. Restarting Apache reloads PHP and its associated modules, including the one we just installed.
To restart Apache, execute the following command as the superuser:
After the server has restarted, the GD image library will be installed and loaded.
To confirm that GD has been successfully installed on a system we can run the following command on Ubuntu Linux for example:
The above command will list the modules that are loaded for PHP; look to see if GD is in the list.
Alternately, you can use the phpinfo function to determine if GD is installed. Run the following PHP script:
<?php phpinfo(); ?>
Look for GD in the list of installed modules.
That brings us to the end of this tutorial. Installing GD on Ubuntu is indeed a very simple process!