How to compile and install the GD library separately in the CentOS server

Source: Internet
Author: User
Tags fpm image processing library ini centos centos server

These days has been to get a mall system, the system's source code and database have been uploaded and created. However, when you install the system, you are prompted for a missing GD library. As follows:


Use the PHP probe to see that PHP does not have the GD library installed. As follows:


The current server environment is nginx+php-fpm,php using the source code to minimize the installation, so there is no installation of the GD library. Although the GD library is not installed, we can still install the GD library by compiling it separately.

Let's begin by introducing how to install the GD library for a compiled PHP environment. The installation of the GD library is divided into the following steps:

1, GD library is what

2. Installation libpng

3. Installation FreeType

4. Installation Jpegsrc

5. Install GD Library

6, check the installation of GD library

A, GD library is what

The GD library is an open source image processing library that provides a series of APIs for working with pictures so that they can be used to create diagrams, graphs, thumbnails, and other image processing operations.

The GD library supports common picture formats such as JPG, PNG, and GIF. So before installing the GD library, we need to install libpng, JPEGSRC, FreeType these three software.

Second, install libpng

The Libpng package contains libpng libraries that can be used by other software to process image files for PNG suffixes.

Download libpng, as follows:

wget http://jaist.dl.sourceforge.net/project/libpng/libpng16/1.6.16/libpng-1.6.16.tar.gz


Install Libpng,libpng Installation We use the default option. As follows:

TAR-XF libpng-1.6.16.tar.gz

CD libpng-1.6.16

./configure

Make

Make install



Note: If zlib is already installed on the system, be aware of compatibility issues between the zlib and libpng versions, the zlib-1.2.8 and libpng-1.5.20 are currently known to be installed normally, but the following error will be reported when installing with libpng-1.6.16:


In this article, there are some descriptions of this issue, as follows:

Http://stackoverflow.com/questions/19738464/pngfix-c2151-undefined-reference-to-inflateres

Iii. installation of JPEGSRC

The JPEGSRC package contains JPEG libraries that can be used by other software to process image files for JPG or JPEG suffixes.

Download JPEGSRC, as follows:

wget http://www.ijg.org/files/jpegsrc.v9a.tar.gz



Install JPEGSRC,JPEGSRC Installation We use the default option. As follows:

TAR-XF jpegsrc.v9a.tar.gz

CD jpeg-9a/

./configure

Make && make install



Iv. installation of FreeType

The FreeType library is a completely free, open source, high-quality, portable font engine that provides a unified interface to access a variety of font format files, including TrueType, OpenType, Type1, CID, CFF, Windows fon/fnt, X11 PCF, and so on.

Download FreeType, as follows:

wget http://ftp.twaren.net/Unix/NonGNU/freetype/freetype-2.5.5.tar.gz



Install Freetype,freetype Installation We use the default option. As follows:

TAR-XF freetype-2.5.5.tar.gz

CD freetype-2.5.5

./configure

Make && make install



V. Installation of the GD library

After the installation of the above three software, we now have to compile and install the GD library separately.

Install GD pants Separately, we need to switch to the PHP source package/ext/gd/directory, as follows:

/root/php-5.6.2/ext/gd


Then execute the phpize command in this directory. As follows:

/usr/local/bin/phpize


Why use the Phpize command? Because when we need to add some more modules, but do not want to recompile PHP, then we can use the Phpize command.

Note: The Phpize command is based on the location of the PHP installation and I use the default installation location for this PHP installation.

You can now install the GD library separately, as follows:

./configure--with-php-config=/usr/local/bin/php-config

Make && make install



Then modify the php.ini file to add a row of extension=gd.so under the Dynamic Extensions module of the file. As follows:

Vi/usr/local/lib/php.ini

Extension=gd.so


If you do not know the location of the php.ini file, we can view it through the PHP--ini command, as follows:

PHP--ini


VI. Check the installation of GD library

After the GD library is installed and the php.ini file is modified, we can see if the GD module is loaded successfully through the PHP? m command. As follows:

/usr/local/bin/php-m |grep GD


Note: Php? m is the command to see which modules are installed in PHP.

/usr/local/bin/php-m


From the above diagram, we can clearly see that the GD module has been properly loaded.

Now let's restart Nginx and PHP-FPM, and then see if the GD Library is installed successfully, as follows:

/usr/local/nginx/sbin/nginx-s Reload

/ETC/INIT.D/PHP-FPM restart



From the above figure, we can see that the GD Library has been successfully installed.

If it's Apache, we can do that too.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.