安装php的gd库插件--搭建网站(6)

本文详细介绍了在Linux环境下,如何通过命令行安装并配置GD库、JPEG、PNG、FREETYPE、ZLIB、GETTEXT等依赖库,并最终实现GD库与PHP的集成。包括解决安装过程中遇到的各种错误,如ftdump.c文件中的编译错误,以及libtool的链接错误等问题。

首先下载以下源码包

http://google-desktop-for-linux-mirror.googlecode.com/files/gd-2.0.35.tar.gz
http://down1.chinaunix.net/distfiles/jpegsrc.v6b.tar.gz
ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.5.2.tar.gz
http://google-desktop-for-linux-mirror.googlecode.com/files/zlib-1.2.3.tar.gz
http://down1.chinaunix.net/distfiles/freetype-1.3.1.tar.gz
http://down1.chinaunix.net/distfiles/gettext-0.16.1.tar.gz

安装zlib

tar xvzf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure
make && make install

安装freetype

tar xvzf freetype-1.3.1.tar.gz
cd freetype-1.3.1
./configure --prefix=/usr/local/freetype
make && make install

有多行错误类似:ftdump.c:172:1: error: pasting “.” and “glyph_object” does not give a valid preprocessing token

解决方法:修改 test/ftdump.c 里面的代码:

将 Print_Mem( memory_footprint.##field, string ) 改为: Print_Mem( memory_footprint.field, string )

将 #define FOOTPRINT( field ) Save_Memory( &memory_footprint.##field ) 改为: #define FOOTPRINT( field ) Save_Memory( &memory_footprint.field )

重新make && make instal

或者修改Makefile.in:

  1. 去掉all: ttlib tttest ttpo中的tttest

  2. 删除

install:
cd $(FTLIBDIR); $(MAKE) -f $(MAKEFILE) install
cd $(FTTESTDIR); $(MAKE) -f $(MAKEFILE) install
cd $(FTPODIR); $(MAKE) install
中的 cd $(FTTESTDIR); $(MAKE) -f $(MAKEFILE) install

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

安装libpng

tar xvzf libpng-1.5.2.tar.gz
cd libpng-1.5.2
./configure --prefix=/usr/local/libpng 
make && make install

安装jpegsrc

tar xvzf jpegsrc.v6b.tar.gz
cd jpegsrc.v6b
./configure --prefix=/usr/local/jpeg6  --enable-shared --enable-static
make && make install

可能的错误:提示文件夹不存在,应该是程序不能自动创建文件夹吧,根据提示的错误,手动用mkdir创建文件就可以了。

本次例如:

mkdir -p /usr/local/jpeg6/include/
mkdir -p /usr/local/jpeg6/lib/
mkdir -p /usr/local/jpeg6/bin/cjpeg
mkdir -p /usr/local/jpeg6/man/man1/

安装gettext(有的直接就有,可以先安装GD库,报错再返回来安装)

tar xvzf gettext-0.16.1.tar.gz
cd gettext-0.16.1
./configure --prefix=/usr/local/gettext
make && make install

安装GD

tar xvzf gd-2.0.35.tar.gz
cd gd-2.0.35
./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg6 --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype
make
make install

configure…这一步可能的错误:configure.ac:64: error: possibly undefined macro: AM_ICONV,这个就必须安装gettext(步骤6中有讲)

生成gd.so

cd ../php-5.2.17/ext/gd/                # 下载的安装包所在目录
/usr/local/php5/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-jpeg-dir=/usr/local/jpeg6/ --with-png-dir=/usr/local/libpng/ --with-gd=/usr/local/gd/ --with-freetype=/usr/local/freetype/
make && make install

这时在make install的结尾会有gd库存放的位置,从那个文件夹中将gd.so复制到扩展库目录中

修改PHP.ini

在php.ini中添加如下内容

extension=gd.so

安装结束,重启Apache服务

./httpd -k restart

遇到的问题

问题一

libtool: link: `ext/standard/***.lo' is not a valid libtool object
解决方案:
不知道什么原因造成的。但这样可以解决:
删了源码目录,重新解压源码,编译、安装。

问题二

安装jpg时候,如果出错。
1.先装libtool
下载地址
http://ftp.gnu.org/gnu/libtool/libtool-2.2.6a.tar.gz //是我下载的版本

./configure 
make 
make install

再装jpegsrc.v6b.tar.gz

./configure  --enable-shared  --enable-static  #这些lib这种包用默认路径就行。不然如果其他的需要这个包还得指它的路径

这里可能会出错
checking host system type… Invalid configuration x86_64-unknown-linux-gnu ‘: machinex86_64-unknown ‘ not recognized

checking build system type… Invalid configuration x86_64-unknown-linux-gnu ‘: machinex86_64-unknown ‘ not recognized

configure: error: libtool configure failed

或者

/libtool --mode=compile gcc -O2  -I. -c ./jcapimin.c 
make: ./libtool:命令未找到 
make: *** [jcapimin.lo] 错误 127 
./libtool --mode=compile gcc -O2  -I. -c ./cjpeg.c 
make: ./libtool:命令未找到 
make: *** [cjpeg.lo] 错误 127

解决方法

cp /usr/share/libtool/config/config.guess . 
cp /usr/share/libtool/config/config.sub . 
cp到jpeg的安装文件目录,注意后面的个“.” 
make clean

再重新

./configure --prefix=/usr/local/libjpeg/   --enable-shared  --enable-static 
make 
make install

参考文章:
http://www.52web.me/35.html
http://www.2cto.com/os/201203/124094.htmlhttp://www.myexception.cn/linux-unix/1607765.html


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值