Linux Centos server opens GD library configuration PHP yum installation support

Enabling GD libraries and configuring PHP yum installation support on a Linux CentOS server

When using a website for SEO to promote a WeChat official account , if you want to improve the website's user experience, it's best to change to a more attractive website template or WordPress theme.

In light of this, Chen Weiliang has stopped researching online marketing these past few days and has instead been testing the installation of a powerful WordPress theme, specifically requiring that the Linux server must have GD library enabled.

So, I checked the Linux server with the command to make sure the GD library is installed.

Linux command to detect whether GD library is installed:

php -i | grep -i --color gd

Explain in detail what the GD library is used for

The GD library provides a series of APIs that can process images. Using the GD library allows websites to process images or generate images.

E-commerce website servers typically have the GD library enabled to perform the following functions:

  • Used to generate thumbnails.
  • Add watermark to pictures.
  • Let website data generate reports.

Install GD library on Linux server

  • If the GD library is not installed, please refer to the following method to install the GD library on the Linux server.

# If the source code is installed, add parameters ▼

 --with-gd

# If it is a Debian-based Linux service period, use apt-get to install ▼

 apt-get install php5-gd

# If it is a CentOS server, install it with yum ▼

 yum install php-gd

# If it is a suse-based Linux server, install it with yast▼

 yast -i php5_gd

We can add ▼ when compiling PHP originally does not support GD library

  1. First download the zlib source code, libpng source code, gd source code
  2. After decompression, go to the source directory, zlib directory

Code example ▼

./configure --prefix=/usr/local/zlib
 make ; make install
 make clean

# libpng directory ▼

 cp scripts/makefile.linux ./makefile
 ./configure --prefix=/usr/local/libpng
 make ; make install
 make clean

# gd directory ▼

 ./configure --prefix=/usr/local/libgd --with-png=/usr/local/libpng
 make ; make install
 make clean

Finally, in the php.ini file, search for "gd".

Add this line below ▼

extension=/usr/local/libgdgd.so

Then, restart the php service; if that doesn't work, try reboot Server, usually this is fine.

Attention points

However, if the GD library is installed from the source code, and only the gd library is added, the PHP version and the library version may be different.

If it is a source code installation, it is best to add the parameter –with-gd when compiling PHP

Comment

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

Scroll to Top