Linux下安装PHP的GD支持库

1、安装 zlib

tar -zxf zlib-1.2.3.tar.gz 
cd zlib-1.2.3 
./configure –prefix=/usr/local/zlib 
make 

make install

2、安装 jpeg

mkdir -p /usr/local/libjpeg
mkdir -p /usr/local/libjpeg/bin
mkdir -p /usr/local/libjpeg/lib
mkdir -p /usr/local/libjpeg/include
mkdir -p /usr/local/libjpeg/man
mkdir -p /usr/local/libjpeg/man/man1
tar -zxf jpeg-6b.tar.gz
cd jpeg-6b
./configure –prefix=/usr/local/libjpeg –enable-shared –enable-static
make
make install

3.安装libpng
tar jxvf libpng-1.2.8.tar.bz2
cd libpng-1.2.8
mv ./scripts/makefile.linux ./makefile
make
make install
注意,里的makefile不是用./configure生成,而是直接从scripts/里拷一个

4.安装freetype

tar -zxf freetype-2.3.5.tar.gz 
cd freetype-2.3.5
mkdir -p /usr/local/freetype 
./configure –prefix=/usr/local/freetype 
make 

make install

5.安装GD

tar -zxf gd-2.0.33.tar.gz 
cd gd-2.0.33 
mkdir -p /usr/local/gd2 
./configure –prefix=/usr/local/gd2 –with-jpeg=/usr/local/libjpeg/ –with-png=/usr/local/lib/ –with-zlib=/usr/local/lib/ –with-freetype=/usr/local/freetype/ 
make 

make install

---------------在安装jpeg的过程中,如果出现如下错误:

make: ./libtool: Command not found
make: *** [jcapimin.lo] Error 127

错误分析:由于libtool版本过低导致的,重新下载新版本的libtool以默认方式安装,执行以下命令:

./configure
make
make install

然后进入jpeg-6b的源码目录,然后执行以下步骤:

cp /usr/share/libtool/config.sub .
cp /usr/share/libtool/config.guess .

cp到jpeg的安装文件目录,注意后面的个“.”


./configure --enable-shared --enable-static

make clean
make
mkdir -p /usr/local/man/man1 等等mkdir
make install

6.

6.1
如果已经安装php,建议通过追加编译安装GD:
进入“[php解压目录]/ext/gd”目录,执行如下命令:
[php安装目录]/bin/phpize

./configure --with-php-config=[php安装目录]/bin/php-config --with-jpeg=[jpeg-6b安装目录] --with-png=[libpng安装目录] --with-freetype=[freetype安装目录] --with-gettext=[gettext安装目录] --with-gd=[gd安装目录]  
make  
make install  
 
安装成功后会在“[php安装目录]/lib/php/extensions/no-debug-non-zts-20060613”目录下生成gd.so文件,
   然后cp [php安装目录]/lib/php/extensions/no-debug-non-zts-20060613/gd.so /opt/php/ext
 
修改php.ini文件加载gd组件,添加extension_dir=/opt/php/ext和extension=gd.so,如果有extension_dir=/opt/php/ext则不需要增加

extension_dir=/opt/php/ext  
extension=gd.so  

6.2
在重新安装PHP:
cd php-5.3.13
./configure (以前的参数) --with-gd --enable-gd-native-ttf --with-zlib-dir=/usr/local/zlib --with-png --with-jpeg --with-freetype-dir=/usr/local/freetype
make clean
make
make install

---------------------------------遇到的问题:

1.make: Nothing to be done for `all'

解决方法:

这句提示是说明你已经编译好了,而且没有对代码进行任何改动。 若想重新编译,可以先删除以前编译产生的目标文件:
make clean
然后再
make

2.make: Nothing to be done for `unix'.

解决方法:

 builds/unix在freetype下载解压的目录下。
 先进入 builds/unix目录,然后在里边运行./configure命令,运行该命令不会出现上边错误。
'cd' into builds/unix, and run the './configure' from there, then 'cd' back  to the freetype-2.1.8  and make .

3.

安装php make的时候提示如下出错信息:

/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status
make: *** [libphp5.la] Error 1

解决方法:

cd  src/libmcrypt-2.5.7/libltdl

./configure  –enable-ltdl-install

make

make install

然后退回到php的解压文件夹

make clean

./configure--等等参数

make
make install

参考链接:

http://www.2cto.com/os/201203/124094.html

http://www.mycodes.net/down_details.php?id=1505

原文地址:https://www.cnblogs.com/dami520/p/2989910.html