CentOS Standalone Compilation install PHP GD library extension

Source: Internet
Author: User

The site of the second server run the environment is mainly python/ruby, and sometimes need to run PHP script, so also installed PHP, the environment is nginx+php-fpm,php is the source code compiled and installed, so it is minimized installation, even mysqli extension is not. Today needs to use the GD library, only to find that there is no GD library environment, so need to install this extension. For individual extensions, it is easier and quicker to compile dynamic loads separately. Installation process is also more complicated, this record, convenient later.

First of all, my PHP is compiled by the source code installation, you can see the source code compiled by the way to install PHP and PHP-FPM.

First install GD front-facing library: FreeType, Jpegsrc,libpng. Gambling King Casino

1. FreeType

wget "http://download.savannah.gnu.org/releases/freetype/freetype-2.4.0.tar.bz2" Tar jxvf freetype-2.4.0.tar.bz2cd Freetype-2.4.0./configure--prefix=/usr/local/freetype && make && make install

2. Jpegsrc

wget "http://www.ijg.org/files/jpegsrc.v9.tar.gz" tar zxvf jpegsrc.v9.tar.gzcd jpeg-9cflags= "-o3-fpic"./configure-- Prefix=/usr/local/jpeg && make && make installmkdir-p/usr/local/jpeg/includemkdir-p/usr/local/jpeg/ Libmkdir-p/usr/local/jpeg/binmkdir-p/usr/local/jpeg/man/man1

3. libpng

Wget "http://downloads.sourceforge.net/project/libpng/libpng12/1.2.50/libpng-1.2.50.tar.gz?r=http%3A%2F% 2FWWW.LIBPNG.ORG%2FPUB%2FPNG%2FLIBPNG.HTML&TS=1376631135&USE_MIRROR=NCHC "  Tar zxvf LIBPNG-1.2.50.TAR.GZCD libpng-1.2.50 cflags= "-o3-fpic"./configure--prefix=/usr/local/libpng && Make & & Make Install

Next need CD to PHP source of GD directory, otherwise will report cannot find config.m4 such as errors.

CD PHP-5.3.6CD Extcd GD

Then this directory executes the command/usr/local/php/bin/phpize. When do I need to use phpize? When we need to add more modules and don't want to recompile PHP, we can use Phpize. My PHP is installed in the/usr/local/php/directory, can be modified according to personal circumstances.

/usr/local/php/bin/phpize

It is now possible to compile the installation separately:

./configure--with-php-configure=/usr/local/php/bin/php-config  --with-jpeg-dir=/usr/local/jpeg  -- With-png-dir=/usr/local/libpng   --with-freetype-dir=/usr/local/freetype or./configure--with-php-config=/usr/ Local/php/bin/php-config  --with-jpeg-dir=/usr/local/jpeg  --with-png-dir=/usr/local/libpng   -- With-freetype-dir=/usr/local/freetypemake && make Install

Then modify the php.ini file to add a line under; Extension=php_zip.dll extension=gd.so

Restart Nginx and see if the installation is successful. Then perform/usr/local/php/bin/php-m to see if the GD module is loaded successfully.

Service Nginx Restart/usr/local/php/bin/php-m

Console lists:

[Email protected] gd]#/usr/local/php/bin/php-m[php MODULES]CORECTYPEDATEDOMEREGFILEINFOFILTERGD ...

See GD, the installation of the GD library is successful.

Next, just restart PHP-FPM:

Killall PHP-FPM/USR/LOCAL/PHP/SBIN/PHP-FPM

CentOS Standalone Compilation install PHP GD library extension

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.