一、YUM源安装GD库 
#yum install php-gd*

二、源码安装GD库
下载
zlib-1.2.2.tar.gz
jpegsrc.v6b.tar.gz
libpng-1.2.7.tar.tar
freetype-2.1.9.tar.gz
gd-2.0.33.tar.gz
安装
1.安装zlib
# tar zxvf zlib-1.2.5.tar.gz //解压
# cd zlib-1.2.5 //改变目录
# CFLAGS=”-O3 -fPIC” ./configure   //使用64位的方法进行编译 (一般只需要./configure)
# make
# make install
2.2.安装libpng
tar zxvf libpng-1.2.7.tar.tar
cd libpng-1.2.7
cd scripts/
mv makefile.linux ../makefile
cd ..
make
make install
注意,这里的makefile不是用./configure生成,而是直接从scripts/里拷一个
3.安装freetype
tar zxvf freetype-2.1.9.tar.gz
cd freetype-2.1.9
./configure --prefix=/usr/local/modules/freetype 
make
make install
d.jpeg
# wget http://www.ijg.org/files/jpegsrc.v8b.tar.gz //下载
# tar jpegsrc.v8b.tar.gz //解压
# cd jpeg-8b //改变目录
# ./configure –prefix=/usr/local/modules/jpeg7 –enable-shared –enable-static  //配置
# make //编译
# make install  //安装

e.GD
# wget http://www.boutell.com/gd/http/gd-2.0.33.tar.gz //下载
# tar xzvf gd-2.0.33.tar.gz //解压
# cd gd-2.0.33 //改变目录
# ./configure –prefix=/usr/local/modules/gd –with-jpeg=/usr/local/modules/jpeg7 –with-png=/usr/local/libpng –with-zlib –with-freetype=/usr/local/modules/freetype  //配置
# make //编译
# make install  //安装

4.PHP
a.libxml2  //只拓展gd,这个可以不装
# wget ftp://xmlsoft.org/libxml2/libxml2-2.7.2.tar.gz //下载
# tar zxvf libxml2-2.7.2.tar.gz //解压
# cd libxml2-2.7.2 //改变目录
# ./configure –prefix=/usr/local/libxml2 //配置
# make //编译
# make install //安装
b.curl (系统安装了就yum remove curl,然后下载一个新版的)  //只拓展gd,这个可以不装
# wget http://curl.haxx.se/download/curl-7.19.0.tar.gz //下载
# tar -zxvf curl-7.19.0.tar.gz //解压
# cd curl-7.19.0 //改变目录
# ./configure –prefix=/usr/local/curl //配置
# make //编译
# make install //安装
c.PHP
# wget http://cn.php.net/get/php-5.2.8.tar.bz2/from/us.php.net/mirror
# tar jxvf php-5.2.8.tar.bz2
# cd php*
./configure --prefix=/opt/app/php5 --with-mysql=/opt/app/mysql --with-curl=/opt/app/curl --with-gd=/usr/local/modules/gd --enable-gd-native-ttf --with-jpeg-dir=/usr/local/modules/jpeg7 --with-png-dir=/usr/local/libpng --with-freetype-dir=/usr/local/modules/freetype --with-zlib --enable-fastcgi --enable-debug --enable-sockets    //只拓展gd的安装步族,curl是先前安装的
 
# ./configure –prefix=/usr/local/php –with-mysql=/usr/local/mysql –with-libxml-dir=/usr/local/libxml2 –with-gd=/usr/local/modules/gd –with-png-dir=/usr/local/libpng –with-jpeg-dir=/usr/local/modules/jpeg6 –with-zlib  –with-freetype-dir=/usr/local/modules/freetype –enable-magic-quotes –with-apxs2=/usr/local/apache/bin/apxs  –enable-ftp –with-config-file-path=/usr/local/php/etc –with-iconv –with-gettext –with-curl=/usr/local/curl
# make
# make install
重启php即可
# cp php.ini-dist /usr/local/php/etc/php.ini  (这句。。。)