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之類的即可生效

驗證

 

 

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