CentOS compilation and installation of gd library

Source: Internet
Author: User
Tags image processing library

CentOS compilation and installation of gd library

I have been working on a mall system these days. The source code and database of the system have been uploaded and created. However, when installing the system, the system prompts that the gd library is missing. As follows:

Use the php probe to check and find that the gd library is not installed in php. As follows:

Currently, the server environment is nginx + php-fpm, and php uses the source code to minimize installation. Therefore, the gd library is not installed. Although the gd library is not installed, we can still compile and install the gd library separately.

Next we will introduce how to install the gd library for the compiled php environment. The installation of the gd library involves the following steps:

1. What is the gd database?

2. Install libpng

3. Install freetype

4. Install composer SRC

5. Install the gd library

6. Check the gd library Installation

I. What is the gd library?

The gd library is an open-source image processing library. It provides a series of APIS for processing images so that it can be used to create charts, graphs, thumbnails, and other image processing operations.

The gd library supports common image formats such as JPG, PNG, and GIF. Therefore, before installing the gd library, we need to install libpng, javassrc, and freetype.

Ii. Install libpng

The libpng package contains the libpng library, which can be used by other software to process image files with the png suffix.

Download libpng as follows:

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

To install libpng and libpng, we use the default options. As follows:

Tar-xf libpng-1.6.16.tar.gz

Cd libpng-1.6.16

./Configure

Make

Make install

NOTE: If zlib has been installed in the system, pay attention to compatibility issues between zlib and libpng versions, currently known zlib-1.2.8 and libpng-1.5.20 can be installed properly, but with the libpng-1.6.16 installation, the following error is reported:

This article describes the problem as follows:

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

3. Install composer SRC

The jpegsrc software package contains jpeg libraries which can be used by other software to process jpg or jpeg image files.

Download unzip SRC as follows:

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

We use the default options for installing composer SRC and composer SRC. As follows:

Tar-xf restart src.v9a.tar.gz

Cd jpeg-9a/

./Configure

Make & make install

4. Install freetype

The freetype library is a completely free, open-source, high-quality and portable font engine. It provides a unified interface to access a variety of font format files, including TrueType, OpenType, Type1, CID, CFF, Windows FON/FNT, and X11 PCF.

Download freeType as follows:

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

Install freetype. We use the default option for freetype installation. As follows:

Tar-xf freetype-2.5.5.tar.gz

Cd freetype-2.5.5

./Configure

Make & make install

5. Install the gd library

After the above three software are installed, We will compile and install the gd library separately.

Compile and install the gd pants separately. We need to switch to the/ext/gd/directory of the php source code package, as shown below:

/Root/php-5.6.2/ext/gd

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

/Usr/local/bin/phpize

Why should I use the phpize command? Because when we need to add some modules but do not want to re-compile php, we can use the phpize command.

Note: The phpize command depends on the php installation location. The default installation location is used for php installation.

Now you can compile and install the gd library separately, as shown below:

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

Make & make install

Modify the php. ini file and add a line 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, run the php -- ini command as follows:

Php -- ini

Vi. Check the gd library Installation

After the gd library is installed and the php. ini file is modified, run the php-m command to check whether the gd module is successfully loaded. As follows:

/Usr/local/bin/php-m | grep gd

Note: php-m is a command to check which modules are installed in php.

/Usr/local/bin/php-m

We can see that the gd module has been correctly loaded.

Now let's restart nginx and php-fpm, and then check whether the gd library is successfully installed, as shown below:

/Usr/local/nginx/sbin/nginx-s reload

/Etc/init. d/php-fpm restart

We can see that the gd library has been successfully installed.

If it is apache, we can install it like this.

This article from the "muddy world" blog, please be sure to keep this source http://ilanni.blog.51cto.com/526870/1611402

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.