Linux下安装PHP的GD支持库

时间:2021-12-31 08:20:45

Linux下安装PHP的GD支持库

 

1、安装 zlib 

wget ftp://ftp.sunfreeware.com/pub/freeware/SOURCES/zlib-1.2.3.tar.gz 
tar -zxf zlib-1.2.3.tar.gz 
cd zlib-1.2.3 
./configure –prefix=/usr/local/zlib 
make 
make install 
 

2、安装 jpeg

wget ftp://ftp.sunfreeware.com/pub/freeware/SOURCES/jpeg-6b.tar.gz 
mkdir -p /usr/local/jpeg6 
mkdir -p /usr/local/jpeg6/bin 
mkdir -p /usr/local/jpeg6/lib 
mkdir -p /usr/local/jpeg6/include 
mkdir -p /usr/local/jpeg6/man 
mkdir -p /usr/local/jpeg6/man1 
mkdir -p /usr/local/jpeg6/man/man1 
tar -zxf jpeg-6b.tar.gz 
cd jpeg-6b 
./configure –prefix=/usr/local/jpeg6 –enable-shared –enable-static 
make 
make install 
 
安装完成提示: 
Libraries have been installed in: 
/usr/local/jpeg6/lib 
 

3、安装 libpng

wget ftp://ftp.sunfreeware.com/pub/freeware/SOURCES/libpng-1.2.16.tar.gz 
tar -zxf libpng-1.2.16.tar.gz 
cd libpng-1.2.16 
./configure –prefix=/usr/local/libpng 
make 
make install 
 

4、安装 freetype

wget http://download.savannah.nongnu.org/releases/freetype/freetype-2.3.4.tar.gz 
tar -zxf freetype-2.3.4.tar.gz 
cd freetype-2.3.4 
mkdir -p /usr/local/freetype 
./configure –prefix=/usr/local/freetype 
make 
make install 
 

5、安装 GD

wget ftp://ftp.sunfreeware.com/pub/freeware/SOURCES/gd-2.0.33.tar.gz 
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/jpeg6/ –with-png=/usr/local/lib/ –with-zlib=/usr/local/lib/ –with-freetype=/usr/local/freetype/ 
make 
make install 
 
 
-------------------- 
 
安装jpg时候,如果出错。 
 
先装libtool 
 
libtool-1.X.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 ‘: machine `x86_64-unknown ‘ not recognized 
 
checking build system type… Invalid configuration `x86_64-unknown-linux-gnu ‘: machine `x86_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 
 
-------------------------------- 
如果已经安装php,建议通过追加编译安装 
进入“[php解压目录]/ext/gd”目录,执行如下命令: 
[php安装目录]/bin/phpize 
Java代码  
./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则不需要增加 
Java代码  
extension_dir=/opt/php/ext  
extension=gd.so