php编译gd支持gif,编译安装GD库对gif jpg(jpeg) png wbmp xml 和 ttf字

安装GD库,让php对更多图形方面gif jpg(jpeg) png wbmp xml 和 ttf字体 的支持。

可以说如果要配置一台LAMP服务器,都离不开安装gd库,就算自己php开发不涉及到图形方面,

但是如果使用其他一些php开发的工具也会涉及到。

简单介绍一下gd库:

gd库提供了一系列用来处理图片的API,使用GD库可以处理图片,或者生成图片。

在网站上GD库通常用来生成缩略图或者用来对图片加水印或者对网站数据生成报表。

也就是有了gd库,我们用php对图片的处理将会得心应手。

一、安装ncurses

安装gd库会用到的

#tar zxvf ncurses-5\[1\].6.tar.gz -C /usr/local/src

# cd /usr/local/src/ncurses-5.6/

#./configure --prefix=/usr --with-shared --without-debug

# make ; make install

二、安装GD

1. zlib

# tar zxvf zlib-1.2.3.tar.gz -C /usr/local/src/

# cd /usr/local/src/zlib-1.2.3/

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

# make ; make install

2.libpng

# tar zxvf libpng-1.2.26.tar.gz -C /usr/local/src/

# cd /usr/local/src/libpng-1.2.26/

# cp scripts/makefile.linux ./makefile //注意,这里的makefile不是用./configure生成,而是直接从scripts/里拷一个

# ./configure

--prefix=/usr/local/libpng

# make ; make install

3.freetype(ttf)

# tar zxvf freetype-2.3.5.tar.gz -C /usr/local/src

# cd /usr/local/src/freetype-2.3.5/

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

# make ; make install

4.jpegsrc

# tar zxvf jpegsrc.v6b.tar.gz -C /usr/local/src/

# cd /usr/local/src/jpeg-6b/

# mkdir -pv

/usr/local/libjpeg/{,bin,lib,include,man/man1,man1}

上面的命令是要手动创建一些目录,否则configure时候会说找不到目录

# ./configure --prefix=/usr/local/libjpeg --enable-shared

--enable-static

注意,这里configure一定要带--enable-shared参数,不然,不会生成共享库

# make ; make install

5.libxml2

# tar zxvf libxml2-2.6.31.tar.gz -C /usr/local/src/

# cd /usr/local/src/libxml2-2.6.31/

# ./configure --prefix=/usr/local/libxml2

# make ; make install

# cp xml2-config /usr/bin/

6.libmcrypt

# tar zxvf libmcrypt-2.5.7.tar.gz -C /usr/local/src/

# cd /usr/local/src/libmcrypt-2.5.7/

# ./configure

# make ; make install

7.Fontconfig

# tar zxvf fontconfig-2.4.2.tar.gz -C /usr/local/src/

# cd /usr/local/src/fontconfig-2.4.2/

# ./configure --prefix=/usr/local/fontconfig

--with-freetype-config=/usr/local/freetype/bin/freetype-config

如果报错:

checking for LIBXML2...

configure: error: Package requirements (libxml-2.0

>= 2.6) were not met:

No package 'libxml-2.0' found

Consider adjusting the PKG_CONFIG_PATH

environment variable if you

installed software in a non-standard prefix.

Alternatively, you may set the environment

variables LIBXML2_CFLAGS

and LIBXML2_LIBS to avoid the need to call pkg-config.

See the pkg-config man page for more details.

但是我们在上面其实已经安装上 libxml2

了的,这里只是一个环境变量没有设置好而已。

解决办法: 确定 /usr/local/libxml2/lib/pkgconfig

目录下有 libxml-2.0.pc

export

PKG_CONFIG_PATH=/usr/local/libxml2/lib/pkgconfig:$PKG_CONFIG_PATH

再次生成 makefile , 这样就成功了。

# make ; make install

8.安装GD库

# tar zxvf gd-2.0.35.tar.gz -C /usr/local/src/

# cd /usr/local/src/gd-2.0.35/

# ./configure --prefix=/usr/local/libgd

--with-png=/usr/local/libpng --with-freetype=/usr/local/freetype

--with-jpeg=/usr/local/libjpeg

--with-fontconfig=/usr/local/fontconfig

下面出现:表示都支持了

** Configuration summary for gd 2.0.34:

Support for PNG

library: yes

Support for JPEG

library: yes

Support for Freetype 2.x

library: yes

Support for Fontconfig

library: yes

Support for Xpm

library: yes

Support for

pthreads: yes

# make ; make install

编辑/etc/ld.so.conf,添加以下几行到此文件中。

/usr/local/zlib/lib

/usr/local/freetype/lib

/usr/local/libjpeg/lib

/usr/local/libgd/lib

并执行ldconfig命令,使用动态装入器装载找到共享库

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值