Compile and install the PHP gd library extension in CentOS6.5

Source: Internet
Author: User

Compile and install the PHP gd library extension in CentOS6.5

The Workpress environment installed on the server of the company's website a few days ago is mainly to run PHP, the environment is Nginx + php-fpm, PHP is installed in yum, so it is to minimize the installation, php all kinds of extensions are not. Today, we need to use the GD library to find that there is no GD library environment, so we need to install this extension. It is convenient and quick to compile dynamic loading separately to deal with a single extension.

Install the gd pre-database freetype, javassrc, and libpng first.

1. freetype

wgethttp://download.savannah.gnu.org/releases/freetype/freetype-2.4.0.tar.bz2

tar jxvf freetype-2.4.0.tar.bz2

cd freetype-2.4.0

./configure --prefix=/usr/local/freetype && make && make install

2. jpegsrc

wgethttp://www.ijg.org/files/jpegsrc.v9.tar.gz

tar zxvf jpegsrc.v9.tar.gz

cd jpeg-9

CFLAGS="-O3 -fPIC"./configure --prefix=/usr/local/jpeg && make && make install

3. libpng

wgethttp://jaist.dl.sourceforge.net/project/libpng/libpng16/1.6.18/libpng-1.6.18.tar.gz

tar zxvf libpng-1.6.18.tar.gz

cd libpng-1.6.18

CFLAGS="-O3 -fPIC"./configure --prefix=/usr/local/libpng && make && make install

Next, we need to cd to the gd directory of php source code. My php version is 5.3.3. Here is the source code.

http://museum.php.net/php5/php-5.3.3.tar.gz

cd php-5.3.6

cd ext

cd gd

Then execute the command/usr/bin/phpize in this directory. When should I use phpize? When we need to add some modules and don't want to re-compile php, we can use phpize. My PHP is installed in the/usr/bin/directory, which can be modified as needed.

Run the/usr/bin/phpize command

Now you can compile and install it separately:

. /Configure -- with-php-configure =/usr/bin/php-config -- with-jpeg-dir =/usr/local/jpeg -- with-png-dir =/usr/ local/libpng -- with-freetype-dir =/usr/local/freetype

Make & make install

Modify the php. ini file and add a line of extension = gd. so under; default extension directory.

# cat gd.ini

; Enable gd extension module

extension=gd.so

--------------------------------------------------------------------------------

The most important installation is yum install php-gd

Restart Nginx and php and check whether the installation is successful. Run/usr/bin/php-m to check whether the gd module is successfully loaded.

service nginx restart

/etc/init.d/php-fpm restart

#/Usr/bin/php-m

[PHP Modules]

Bz2

Calendar

...

Ftp

Gd

Reference: http://www.nowamagic.net/librarys/veda/detail/2610

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.