How to Install PHP GD on cPanel, CentOS server
How to Install PHP GD library on cPanel, CentOS, Ubuntu, Debian servers
PHP GD graphics library is a PHP extension for creating images and it can be installed on Linux and Windows servers. You can use the PHP extension to create images in formats like JPEG, PNG etc. GD is not only used in PHP, it is also used in other programming languages like perl, python etc.
How to Install PHP GD on CentOS 6 / Redhat 6 Linux server
First you must install the EPEL repository on your CentOS/RHEL server. Run the command “yum install epel-release” to install the EPEL repository. You must enable the repository after the installation.
Download and Install the REMI repository :
rpm -Uvh remi-release-*.rpm
The below steps are for CentOS and Redhat server. Scroll down for Installation steps on cPanel servers.
The PHP package might be different on your server so first you must search the correct package name. Example : The package name might be php-gd, php54-gd, php5.6-gd etc
This will show the exact package name. Change the package name in the below steps accordingly.
1. Log into your Linux server through SSH as ‘root’ user
2. Type the below command to check whether PHP GD is already Installed
3. You can install PHP gd extension using yum
Command to Install PHP GD on CentOS 6 / Redhat 6 Server :
4. You must restart the Apache service after installing the GD library
Command to restart the Apache Service : service httpd restart
5. You must create a phpinfo.php file under your website to verify GD library is installed.
6. Type the below command to check whether php gd is loaded
Steps to Install php-gd on CentOS 7 and RHEL 7 servers is the same. The only difference is you must install REMI repository for CentOS/RHEL 7 before installing php-gd package.
Steps to Uninstall / Remove PHP GD
yum remove php-gd
How to Install PHP GD by Downloading the rpm file
You can also Install PHP GD by downloading the rpm file. You can download the rpm from websites like rpmfind.
IMPORTANT : You must check the OS and architecture before download the rpm file. Example : Do not install 32 bit rpm on a 64 bit server.
1. Log into your Linux server as ‘root’ user
2. Check the server OS release and architecture before downloading the rpm
Run the command “cat /etc/redhat-release” to check the distribution
Run the command “uname -i” to check whether it is 32 bit or 64 bit
3. Download the php-gd rpm file from rpmfind website
URL to download php-gd rpm file :
Download the PHP GD rpm file from rpmfind site to the server using wget command
PHP gd rpm file of Mageia, Mandriva, CentOS, Redhat and Fedora distribution is available in rpmfind website.
4. Run the command “rpm -Uvh php-gd-x.x.x.rpm” to install the downloaded rpm file.
Install PHP GD on Ubuntu / Debian Server
1. Log in to your Ubuntu / Debian Server and run apt-get update
sudo apt-get update
2. Run the below command to Install PHP GD
3. Run the below command to restart the Apache service
service apache2 restart
sudo service apache2 restart
sudo /etc/init.d/apache2 restart
4. Create a phpinfo file under the document root of your website to check whether php GD library is enabled
5. Run the below command to check whether PHP library support is enabled
Command : php -m | grep gd
Steps to Remove / Uninstall php-gd
Run the below command to remove :
How to Install PHP GD library on cPanel Easyapache 3 EA3 server from server backend
1. Log into cPanel server as root user
2. You must always run Easyapache in screen
screen -S easyapache
3. Run the command “/scripts/easyapache” on the server to recompile PHP
4. Click on “Exhaustive Options List” and you must select “GD” under PHP modules
Enabling GD library in easyapache 3 will enable Zlib extension.
5. Click on “Next step” and select “Save and Build”
It might take few minutes to recompile easyapache and the GD extension will be enabled after the recompile is completed.
Install PHP GD on Easyapache 3 Server through WHM
1. Log in to WHM (Webhost manager) with server root login details
2. Search for “Easyapache 3” in the WHM search bar
3. Click on “Easyapache 3” under “Software”
4. Under “4 exhaustive Options List” tick the “GD” extension, like shown in the picture
5. Scroll down to the bottom of the page and click on “Save and Build”
6. Create a phpinfo file under your website to check whether PHP GD library is enabled
How to Install PHP GD on cPanel Easyapache4 EA4 server
Easyapache 3 is scheduled for deprecation in January 2018. The above steps are for servers running old version of Easyapache, do the below steps for Easyapache 4 servers.
1. Log into your Linux server via SSH as ‘root’ user
2. Run the command “/scripts/easyapache –version” to check whether it is a Easyapache 3 or 4 server
3. Run the below command to check, for which PHP versions GD is already installed.
rpm -qa | grep gd
4. Install PHP GD for all PHP version on Easyapache 4 server using yum
yum install ea-php54-php-gd
Command to Install PHP gd for PHP version 5.5 :
yum install ea-php55-php-gd
Command to Install PHP gd for PHP version 5.6 :
yum install ea-php56-php-gd
Command to Install PHP gd for PHP version 7.0 :
yum install ea-php70-php-gd
Command to Install PHP gd for PHP version 7.1 :
yum install ea-php71-php-gd
5. Run the below command to check whether PHP gd is enabled
/opt/cpanel/ea-php54/root/usr/bin/php -m | grep gd
PHP 5.5 :
/opt/cpanel/ea-php55/root/usr/bin/php -m | grep gd
PHP 5.6 :
/opt/cpanel/ea-php56/root/usr/bin/php -m | grep gd
PHP 7.0 :
/opt/cpanel/ea-php70/root/usr/bin/php -m | grep gd
PHP 7.1 :
/opt/cpanel/ea-php71/root/usr/bin/php -m | grep gd
How to uninstall PHP GD on Easyapache 4 Server
Run the below command to Uninstall PHP gd :
How to Install PHP GD through WHM on Easyapache 4 server
PHP gd can be installed either through server backend or via WHM.
1. Log in to WHM using server root login credentials
2. Search for “Easyapache 4” in WHM search bar
3. Click on “Easyapache 4” under “Software”
4. Click on “View all packages” under “Currently Installed Packages” to check whether gd is installed
5. Click on “Customize” next to “Currently Installed packages”
6. Click on “PHP extensions” tab
7. Enable gd extension for all PHP versions and click on “next”
8. In the “Review” tab you must scroll down to the bottom and Click on “Provision”
9. Create phpinfo file under your websites to check whether PHP GD library is enabled.