先下载GD所需要的lib库
wget http://www.ijg.org/files/jpegsrc.v6b.tar.gz
wget wget http://jaist.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.25.tar.bz2
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.3.5.tar.gz
编译安装libjpeg
由于libjpeg自带的ltconfig脚本有问题,所以需要手工从系统里面拷贝一份覆盖
tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
cp /usr/share/libtool/config.* .
./configure –host=Darwin –enable-shared
make
make install
编译安装libpng
tar jxvf libpng-1.2.25.tar.bz2
cd libpng-1.2.25
./configure
make
make install
编译安装freetype
tar zxvf freetype-2.3.5.tar.gz
cd freetype-2.3.5
./configure
make
make install
重新编译PHP,只需要./configure的时候加上以下参数
–with-gd –with-jpeg-dir –with-png-dir –with-zlib-dir –with-freetype-dir –enable-gd-native-ttf
观察configure的log,如果有下面的输出就表示成功了。
checking for GD support… yes
checking for the location of libjpeg… yes
checking for the location of libpng… yes
checking for FreeType 2… yes
编译安装完php后,运行php -m可以看到所包含的模块
如果需要编译为64位的PHP(如core 2 duo的CPU,leopard系统),在configure前先运行下面的命令
export CFLAGS='-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -O2 -pipe' export CXXFLAGS="${CFLAGS}"