linux下交叉编译php 7.1 和 扩展模块GD

GD为php的图形库:

备注:有两种方式,

一,是先编译好gd库,再编译php的时候在./configure 使用--with-gd-dir=gd库路径

二,是编译php后,到php的扩展库路径下编译gd库

这里选用第二种方式:

1,准备工作,根据自己需求准备

必须先安装zlib

zlib ( zlib-1.2.11.tar.gz | http://www.zlib.net/ )

	export CC=mipsel-linux-gcc
	export AR=mipsel-linux-ar
	export LD=mipsel-linux-ld
	export NM=mipsel-linux-nm
	export STRIP=mipsel-linux-strip
	export RANLIB=mipsel-linux-ranlib

    ./configure --prefix=/usr/mips/zlib

    make && make install

选择安装

    1)png :(libpng-1.6.37.tar.gz | http://www.libpng.org/pub/png/libpng.html

        tar -xvf libpng-1.6.37.tar.gz

        cd libpng-1.6.37

        ./configure --host=mipsel-linux --prefix=/usr/mips/png

        make && make install

 

    2)jpeg:(jpegsrc.v9c.tar.gz |  http://www.ijg.org/

        tar -xvf jpegsrc.v9c.tar.gz

        cd jpegsrc.v9c

        ./configure --host=mipsel-linux --prefix=/usr/mips/jpeg

        make && make install

 

    3)webp:(libwebp-0.6.0.tar.gz | https://storage.googleapis.com/downloads.webmproject.org/releases/webp/index.html

        tar -xvf libwebp-0.6.0.tar.gz

        cd libwebp-0.6.0
        ./configure --host=mipsel-linux --prefix=/usr/mips/webp
        make && make install

 

     4)FreeType2 (freetype-2.10.1.tar.gz | http://www.freetype.org/) 

    tar -xvf freetype-2.10.1.tar.gz
    cd freetype-2.10.1
    export ZLIB_CFLAGS=/usr/mips/zlib
    export ZLIB_LIBS=/usr/mips/zlib/lib
    export LIBPNG_CFLAGS=/usr/mips/png
    export LIBPNG_LIBS=/usr/mips/png/lib
    ./configure --host=mipsel-linux --prefix=/usr/mips/freetype --with-png=yes --with-zlib=yes
     make && make install

 

开始编译PHP,如何PHP还没有编译过的话

解压php源码,

tar -xvf php-src-php-7.1.30.tar.gz

cd php-src-php-7.1.30

./buildconf --force

具体编译选项如下:

./configure 
--prefix=/usr/mips/php
--exec-prefix=/usr/local/mips/php
--host=mipsel-linux 
--disable-all 
--enable-json  
--enable-pdo=shared 
--with-pdo-sqlite=shared  
--with-sqlite3 
--with-libxml-dir=/usr/mips/xml (如果需要仔细像zlib编译)
--with-zlib 
--with-zlib-dir=/usr/mips/zlib
-enable-embed=shared 
--with-config-file-path=/usr/local/appweb 
--with-config-file-scan-dir=/usr/local/appweb 
--enable-session 
--enable-maintainer-zts  
--with-gettext 
--enable-ctype 
--with-openssl 
--with-openssl-dir=/opt/JdLinuxLib/mips/usr  
--with-curl=/opt/JdLinuxLib/mips/usr
--with-gd 
--with-jpeg-dir=/usr/mips/jpeg 
--with-png-dir=/usr/mips/png 
--with-webp-dir=/usr/mips/webp

make && make install

 

准备完毕,开始编译GD库

cd php-src-php-7.1.30/ext/gd

执行: /usr/local/mips/php/bin/phpize   (此文件是上面编译php安装后才有的)

上述操作会生成configure

执行 ./configure --with-png-dir=/usr/mips/png --with-freetype-dir=/usr/mips/freetype --with-zlib-dir=/usr/mips/zlib --host=mipsel-linux --with-php-config=/usr/local/mips/php/bin/php-config

执行: make  会在当前目录下的 .libs/gd.so文件

将此gd.so 拷贝到目标环境

 

将相关库拷贝到目标环境

1,拷贝png的动态库

2,拷贝jpeg的动态库

3,拷贝webp的动态库

4,拷贝zlib的动态库

5,拷贝libphp7.so  php到目标环境

6,配置php.ini     : extension=gd.so   (拷贝gd.so 到/usr/lib/libgd.so   :名称需要为libgd.so,否则不生效)

7,重启apach 或者 appweb之类的即可生效

验证

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章