天天看點

linux 編譯php需要的依賴 jpeg,linux 下 php+gd2+freetype+jpeg+png+zlib編譯安裝

事件緣起:discuz背景開啟中文驗證碼提示說不支援freetype,但freetype貌似是需要gd2調用生效的。

于是安裝gd2,安裝gd2的時候順帶安裝了jpeg,png,zlib

所需要的安裝包都已經放置在百度雲盤,下載下傳連結http://pan.baidu.com/share/link?shareid=1837459297&uk=1778705955

linux 編譯php需要的依賴 jpeg,linux 下 php+gd2+freetype+jpeg+png+zlib編譯安裝

接下來就是配置步驟:

1、安裝zlib

tar xf zlib-1.2.7.tar.gz

cd zlib-1.2.7

./configure --prefix=/usr/local/zlib

make

make install

2、安裝 jpeg

tar xf jpegsrc.v9a.tar.gz

cd jpeg-9a

./configure --prefix=/usr/local/jpeg --enable-shared --enable-static

make

make install

3、安裝 libpng

tar xf libpng-1.6.12.tar.gz

cd libpng-1.6.12

./configure --prefix=/usr/local/png

make

make install

4、安裝freetype

tar xf freetype-2.5.3.tar.gz

cd freetype-2.5.3

./configure --prefix=/usr/local/freetype

make

make install

5、安裝gd2

tar xf libgd-2.1.0.gz

cd libgd-2.1.0

./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg/ --with-png=/usr/local/png/ --with-zlib=/usr/local/zlib/ --with-freetype=/usr/local/freetype/

make

make install

(注,版本這裡必須>=2.1.0,否則用php-5.6.0會報錯,可能老版本的php不會報錯)

6、內建PHP GD擴充到PHP裡

本來想在[php目錄]/ext/gd内使用phpize擴充gd子產品的,但是提示沒有config.m4檔案

是以隻能重新編譯php

解除安裝所有跟php相關的包:

rpm -qa|grep php

使用rpm -e 加包名

rpm -e php-4.3.9-3.15

重新編譯php:

tar xf php-5.6.0.tar.gz

cd php-5.6.0

./configure --prefix=/usr/local/php-5.6.0 --with-config-file-path=/usr/local/php-5.6.0/etc --with-config-file-scan-dir=/usr/local/php-5.6.0/etc/conf.d --enable-fpm --with-pear --with-curl --with-gd=/usr/local/gd2 --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/png --with-freetype-dir=/usr/local/freetype --with-zlib-dir=/usr/local/zlib --with-iconv --with-mcrypt --with-mhash --with-zlib --with-xmlrpc --with-xsl --with-openssl --with-mysql --with-mysqli --with-pdo-mysql --with-bz2 --with-gettext --with-xpm-dir=/usr/lib64/

make && make install

最後,重新開機php-fpm以重載php:

php-fpm 關閉:

kill -INT `cat /usr/local/php-5.6.0/var/run/php-fpm.pid`

php-fpm 重新開機:

kill -USR2 `cat /usr/local/php-5.6.0/var/run/php-fpm.pid`

,重新整理phpinfo,看到有支援相關子產品的話就是成功了。

原文:http://www.cnblogs.com/nickqian/p/3974210.html