单独编译安装gd库

    xiaoxiao2021-03-31  39

    我的php是采用源码编译的,

    先安装 gd 前置库 : freetype ,jpegsrc,libpng。

    1.freetype

    wget  http://downloads.sourceforge.net/freetype/freetype-2.7.1.tar.bz2

    tar jxvf freetype-2.7.1.tar.bz2

    cd freetype-2.7.1

    ./configure --prefix=/usr/local/freetype

    make && make install

    2.jpegsrc

    wget http://www.ijg.org/files/jpegsrc.v9.tar.gz

    tar zxvf jpegsrc.v9.tar.gz cd jpeg-9

    CFLAGS="-O3 -fPIC" ./configure --prefix=/usr/local/jpeg

    make && make install

    3.libpng

    wget https://downloads.sourceforge.net/project/libpng/libpng16/1.6.29/libpng-1.6.29.tar.gz

    tar zxvf libpng-1.6.29.tar.gz cd libpng-1.6.29 CFLAGS="-O3 -fPIC" ./configure --prefix=/usr/local/libpng make && make install

    接下来切换到php源码的ext的gd目录

    cd /php-7.1.2/ext/gd

    /usr/local/bin/phpize

    ./configure --with-php-config=/usr/local/bin/php-config --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/libpng --with-freetype-dir=/usr/local/freetype

    make && make install

    修改php.ini文件,添加一行 extension=gd.so

    /etc/init.d/php-fpm restart

    /usr/local/nginx/sbin/nginx -s reload

    然后php -m查看是否加载成功

    如果提示  libpng12.so.0: cannot open shared object file: No such file or directory

    可以通过yum install libpng   来解决

    转载请注明原文地址: https://ju.6miu.com/read-665444.html

    最新回复(0)