php安装gd库扩展

时间:2022-10-29 21:19:55

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

1、安装xpm

 yum install libXpm-devel

2、安装zlib

   wget http://zlib.net/zlib-1.2.8.tar.gz
   tar -xzvf zlib-1.2.8.tar.gz
   cd zlib-1.2.8
   ./configure
   make && make install
   make clean && make distclean
   cd ../

3、安装libjpeg jpeg-9b

   wget http://www.ijg.org/files/jpegsrc.v9b.tar.gz
tar -xzvf jpegsrc.v9b.tar.gz
cd jpegsrc.v9b
./configure \
--prefix=/usr/lib64 \
--enable-shared \
--enable-static

make && make instll
make clean && make distclean
libtool --finish /usr/local/jpeg/lib
cd ../

4、安装libpng

   ftp ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng16/libpng-1.6.26.tar.gz
tar -xzvf libpng-1.6.26.tar.gz
cd libpng-1.6.26

./configure \
--enable-shared \
--enable-static

make && make install
make clean && make && make distclean
cd ../

5、安装freetype2

   wget http://download.savannah.gnu.org/releases/freetype/freetype-2.7.tar.gz
tar -xzvf freetype-2.7.tar.gz
cd freetype-2.7
./configure \
--prefix=/usr/lib64
make && make install
make clean && make distclean
cd ../

6、gd安装

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

   wget https://github.com/libgd/libgd/releases/download/gd-2.2.3/libgd-2.2.3.tar.gz
tar -xzvf libgd-2.2.3.tar.gz
cd libgd-2.2.3

./configure \
--prefix=/usr/lib64 \
--with-jpeg=/usr/lib64 \
--with-png=/usr.lib64 \
--with-zlib \
--with-freetype=/usr/lib64

make && make install
make clean && make distclean
cd ../

7、php安装gd库

  •    静态编译

    ./configure \
--prefix=/usr/local/cp-php-5.6.19 \
--with-apxs2=/usr/local/cp-httpd-2.4.18/bin/apxs \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-png-dir=/usr/lib64 \
--with-jpeg-dir=/usr/lib64 \
--with-freetype-dir=/usr/lib64 \
--with-zlib-dir==/usr/lib64 \
--with-xpm-dir=/usr/lib64/ \
--with-gd=/usr/lib64 \
--with-openssl \
--with-curl \
--with-config-file-path=/usr/local/cp-php-5.6.19/lib \
--enable-calendar \
--enable-mbstring \
--enable-sockets \
--enable-xml \
--enable-json \
--enable-pdo \
--enable-libxml \
--enable-simplexml \
--enable-xmlreader \
--enable-xmlwriter

  •    动态编译

   cd php-5.6.19/ext/gd/
phpize

./configure \
--prefix=/usr/lib64 \
--with-jpeg=/usr/lib64 \
--with-png=/usr.lib64 \
--with-zlib \
--with-freetype=/usr/lib64

make && make install
make clean && make distclean
cd ../

  8、引用资料

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