Bobcares

PHP install GD extension – The smart way

by | Oct 3, 2019

Without pictures, websites would be fairly boring.

However, compressing or cropping images, doing greyscale, etc. can be time-consuming and often error-prone.

Fortunately, using the PHP GD extension take care of all your basic image edit requirements.

At Bobcares, we often get requests to install PHP gd extension as part of our Server Management Services.

Today, let’s get into the details and see how our Support Engineers manage PHP install gd extension and fix errors.

 

How we install GD library for PHP on CentOS

The GD library is a library that offers graphics drawing tools to manage image data. By default, it may not be installed on the server. So, we have to install the GD library manually.

Here, let’s see how our Support Engineers install a GD library for PHP on CentOS

Before getting into the installation procedure, we make sure that if it’s already installed with the following command.

rpm -qa | grep gd

If not, we follow the below steps to install a gd extension.

1. We run the below command to install a gd extension.

yum install php-gd

2. Then, we restart the apache as follows.

service httpd restart

That’s it!. Here we have installed the gd library.

Similarly, adding GD library support involves executing the command:

sudo apt-get install php7.0-gd

After that, we create info.php with one line of code <?php phpinfo(); ?> to test whether or not the gd extension is enabled on the server.

For example, after enabling the extension, the output looks like:

 

 

 

How we fix the gd extension installation errors

At Bobcares, where we have more than a decade of expertise in managing servers, we see many customers face problems while installing gd extension on the server.

Now, let’s see the major reasons for installation error and how our Support Engineers fix the top errors.

 

1. Missing package

Recently, one of our customers had a problem with the gd extension. He had installed php71w-gd and still had this error when uploading a file. The error said,

Intervention \ Image \ Exception \ NotSupportedException
GD Library extension not available with this PHP installation.

On checking, our Support Engineers found that he was using the Laravel web framework on the CentOS7 server and Nginx web server. Also, the gd package was not installed properly.

That means GD Library was missing on the server.

Therefore, we reinstalled php71 and php-gd from Remi’s RPM repository by running this code.

yum --enablerepo=remi-php71 install php-gd

Then, we restarted Nginx and PHP-FPM.

systemctl restart nginx

systemctl restart php-fpm

This is how we fixed the error.

 

2. Missing configuration in php.ini

Every domain has its own php.ini file. It contains information on how PHP applications run under the domain.

Therefore, it should also be enabled in php.ini after installing the module server-wide. Then only the module can take effect on the corresponding domains.

Sometimes, customers may forget to enable it in the php.ini file which results in an error like.

NotSupportedException in Driver.php line 16: GD Library extension not available with this PHP installation.

Then, our Support Engineers add the following line to the php.ini file. If the domain is on a Windows server, we add

extension=php_gd2.dll

Or in a Linux server, we uncomment the line:

extension=php_gd.so

Then, we restart the web server for the changes to take effect.

In Apache,

systemctl restart apache

Or in Nginx,

systemctl restart nginx

This fixes the error and the website works normally.

 

[Need assistance in tasks like PHP install gd extension? We’ll help you.]

 

Conclusion

In short, a GD library is a graphics drawing library that provides tools for modifying image data.  Today, we saw the topmost reasons for the gd extension installation errors and how our Support Engineers manage PHP install gd extension.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF