当前位置:Gxlcms > PHP教程 > linux下安装phpGD支持库的方法

linux下安装phpGD支持库的方法

时间:2021-07-01 10:21:17 帮助过:33人阅读

  1. gd-2.0.33.tar.gz http://www.boutell.com/gd/
  2. jpegsrc.v6b.tar.gz http://www.ijg.org/
  3. libpng-1.2.7.tar.tar http://sourceforge.net/projects/libpng/
  4. zlib-1.2.2.tar.gz http://sourceforge.net/projects/zlib/
  5. freetype-2.1.9.tar.gzhttp://sourceforge.net/projects/freetype/
  6. php-4.3.9.tar.gz http://www.php.com

二、安装

1.安装zlib

  1. tar zxvf zlib-1.2.2.tar.gz
  2. cd zlib-1.2.2
  3. ./configure
  4. make
  5. make install

2.安装libpng

  1. tar zxvf libpng-1.2.7.tar.tar
  2. cd libpng-1.2.7
  3. cd scripts/
  4. mv makefile.linux ../makefile
  5. cd ..
  6. make
  7. make install

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

3.安装freetype

  1. tar zxvf freetype-2.1.9.tar.gz
  2. cd freetype-2.1.9
  3. ./configure
  4. make
  5. make install

4.安装Jpeg

  1. tar zxvf jpegsrc.v6b.tar.gz
  2. cd jpeg-6b/
  3. ./configure --enable-shared
  4. make
  5. make test
  6. make install

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

5.安装GD

  1. tar zxvf gd-2.0.33.tar.gz
  2. cd gd-2.0.33
  3. ./configure --with-png --with-freetype --with-jpeg
  4. make install

上面的安装步骤是没有设定 安装目录的,测试重新编译PHP时用上面方法均可。 若要指定安装地址,请采用如下方式,推荐定义安装目录。 1、安装 zlib

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

2、安装 jpeg

  1. wget ftp://ftp.sunfreeware.com/pub/freeware/SOURCES/jpeg-6b.tar.gz
  2. mkdir -p /usr/local/jpeg6
  3. mkdir -p /usr/local/jpeg6/bin
  4. mkdir -p /usr/local/jpeg6/lib
  5. mkdir -p /usr/local/jpeg6/include
  6. mkdir -p /usr/local/jpeg6/man
  7. mkdir -p /usr/local/jpeg6/man1
  8. mkdir -p /usr/local/jpeg6/man/man1
  9. tar -zxf jpeg-6b.tar.gz
  10. cd jpeg-6b
  11. ./configure –prefix=/usr/local/jpeg6 –enable-shared –enable-static
  12. make
  13. make install

安装完成提示: Libraries have been installed in: /usr/local/jpeg6/lib 3、安装 libpng

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

4、安装 freetype

  1. wget http://download.savannah.nongnu.org/releases/freetype/freetype-2.3.4.tar.gz
  2. tar -zxf freetype-2.3.4.tar.gz
  3. cd freetype-2.3.4
  4. mkdir -p /usr/local/freetype
  5. ./configure –prefix=/usr/local/freetype
  6. make
  7. make install

5、安装 GD

  1. wget ftp://ftp.sunfreeware.com/pub/freeware/SOURCES/gd-2.0.33.tar.gz
  2. tar -zxf gd-2.0.33.tar.gz
  3. cd gd-2.0.33
  4. mkdir -p /usr/local/gd2
  5. ./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/
  6. make
  7. make install

安装jpg时,如果出错,需要先装libtool: libtool-1.X.tar.gz //是我下载的版本

  1. ./configure
  2. make
  3. make install
  4. 再装jpegsrc.v6b.tar.gz
  5. ./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 ./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则不需要增加 extension_dir=/opt/php/ext extension=gd.so

人气教程排行