php安装gd库扩展

   gd库主要是用来图像渲染的。gd库依赖以下libjpeg、libpng、freetype2、xpm等安装库。在PHP中启用gd扩展有两种方式一个是动态编译方式,一个是静态编译方式。动态编译方式不需要重新编译php,静态编译方式必须重新编译php。但是无论是动态编译还是静态编译都要先安装gd的相关依赖库文件,并且在编译gd时加到configure参数中。

1、安装xpm

[plain]  view plain  copy
 print ?
  1. yum install libXpm-devel  

2、安装zlib

[plain]  view plain  copy
 print ?
  1.    wget http://zlib.net/zlib-1.2.8.tar.gz  
  2.    tar -xzvf zlib-1.2.8.tar.gz  
  3.    cd zlib-1.2.8  
  4.    ./configure   
  5.    make && make install  
  6.    make clean && make distclean  
  7.    cd ../   

3、安装libjpeg jpeg-9b

[plain]  view plain  copy
 print ?
  1. wget http://www.ijg.org/files/jpegsrc.v9b.tar.gz  
  2. tar -xzvf jpegsrc.v9b.tar.gz  
  3. cd jpegsrc.v9b  
  4. ./configure \  
  5. --prefix=/usr/lib64 \  
  6. --enable-shared \  
  7. --enable-static   
  8.   
  9. make && make instll  
  10. make clean && make distclean  
  11. libtool --finish /usr/local/jpeg/lib  
  12. cd ../  

4、安装libpng

[plain]  view plain  copy
 print ?
  1. ftp ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng16/libpng-1.6.26.tar.gz  
  2. tar -xzvf libpng-1.6.26.tar.gz  
  3. cd libpng-1.6.26  
  4.   
  5. ./configure \  
  6. --enable-shared \  
  7. --enable-static   
  8.   
  9. make && make install  
  10. make clean && make && make distclean  
  11. cd ../  

5、安装freetype2

[plain]  view plain  copy
 print ?
  1. wget http://download.savannah.gnu.org/releases/freetype/freetype-2.7.tar.gz  
  2. tar -xzvf freetype-2.7.tar.gz  
  3. cd freetype-2.7  
  4. ./configure \  
  5. --prefix=/usr/lib64  
  6. make && make install   
  7. make clean && make distclean  
  8. cd ../  

6、gd安装

   php安装时使用--with-gd必须要执行以下命令,在直接安装gd库是不需要试用-dir,但是在php安装的时候需要-dir
  

[plain]  view plain  copy
 print ?
  1. wget https://github.com/libgd/libgd/releases/download/gd-2.2.3/libgd-2.2.3.tar.gz  
  2. tar -xzvf libgd-2.2.3.tar.gz  
  3. cd libgd-2.2.3  
  4.   
  5. ./configure \  
  6. --prefix=/usr/lib64 \  
  7. --with-jpeg=/usr/lib64 \  
  8. --with-png=/usr.lib64 \  
  9. --with-zlib \  
  10. --with-freetype=/usr/lib64  
  11.   
  12. make && make install  
  13. make clean && make distclean  
  14. cd ../  

7、php安装gd库

  •    静态编译

[plain]  view plain  copy
 print ?
  1. ./configure \  
  2. --prefix=/usr/local/cp-php-5.6.19 \  
  3. --with-apxs2=/usr/local/cp-httpd-2.4.18/bin/apxs \  
  4. --with-mysql=mysqlnd \  
  5. --with-mysqli=mysqlnd \  
  6. --with-pdo-mysql=mysqlnd \  
  7. --with-png-dir=/usr/lib64 \  
  8. --with-jpeg-dir=/usr/lib64 \  
  9. --with-freetype-dir=/usr/lib64 \  
  10. --with-zlib-dir==/usr/lib64 \  
  11. --with-xpm-dir=/usr/lib64/ \  
  12. --with-gd=/usr/lib64 \  
  13. --with-openssl \  
  14. --with-curl \  
  15. --with-config-file-path=/usr/local/cp-php-5.6.19/lib \  
  16. --enable-calendar \  
  17. --enable-mbstring \  
  18. --enable-sockets \  
  19. --enable-xml \  
  20. --enable-json \  
  21. --enable-pdo \  
  22. --enable-libxml \  
  23. --enable-simplexml \  
  24. --enable-xmlreader \  
  25. --enable-xmlwriter   

  •    动态编译

[plain]  view plain  copy
 print ?
  1. cd php-5.6.19/ext/gd/  
  2. phpize  
  3.   
  4. ./configure \  
  5. --prefix=/usr/lib64 \  
  6. --with-jpeg=/usr/lib64 \  
  7. --with-png=/usr.lib64 \  
  8. --with-zlib \  
  9. --with-freetype=/usr/lib64  
  10.   
  11. make && make install  
  12. make clean && make distclean  
  13. cd ../  

  8、引用资料

     http://php.NET/manual/zh/image.installation.php

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值