busybox filesystem matrix-gui-2.0 undefined function json_encode()

/********************************************************************************
 *               matrix-gui-2.0 undefined function json_encode() 
 * 声明:
 *     本文解决matrix-gui-2.0中遇到的:
 *     Fatal error: 
 *     Call to undefined function json_encode() in /www/generate.php on line 134
 *     以及busybox httpd找不到index.html,主要是由于index.html被替换成了index.php
 *
 *                                          2016-1-31 深圳 南山平山村 曾剑锋
 *******************************************************************************/


一、参考文章:
    1. PHP移植
        http://www.cnblogs.com/dancheblog/p/3508675.html
    2. Ubuntu Correct path to libxml2 when configuring PHP 5
        https://www.howtoforge.com/community/threads/ubuntu-correct-path-to-libxml2-when-configuring-php-5.9982/
    3. 编译安装php
        http://www.cnblogs.com/alexqdh/archive/2012/11/20/2776017.html
    4. linux下安装PHP出现错误 求助大家了
        http://bbs.chinaunix.net/thread-1962843-1-1.html
    5. Using the busybox HTTP server
        http://wiki.chumby.com/index.php?title=Using_the_busybox_HTTP_server

二、下载、编译libxml2-2.7.6.tar.gz
    1. https://buildroot.org/downloads/
    2. sudo ./configure --host=arm-linux-gnueabihf --prefix=/usr/local/php && make && make install
    3. 注意配置好编译器环境变量。

三、 下载、编译zlib-1.2.8.tar.gz
    1. http://www.zlib.net/
    2. sudo CC=arm-linux-gnueabihf-gcc ./configure --shared --prefix=/usr/local/php && make && make install
    3. 注意配置好编译器环境变量。

四、重新编译php-5.5.31.tar.bz2
    ./configure --host=arm-linux-gnueabihf --prefix=/usr/local/php --disable-all --enable-fastcgi --enable-session --enable-tokenizer --enable-pdo --with-sqlite --with-sqlite3 --with-pdo-sqlite --with-pcre-regex  --without-iconv --with-libxml-dir=/usr/local/php --enable-libxml --enable-spl --enable-simplexml --enable-json --with-zlib --with-zlib-dir=/usr/local/php
    
五、error:
    1. 错误1:
        1. 错误现象:
            ......
            checking whether to enable LIBXML support... yes
            checking libxml2 install dir... no
            checking for xml2-config path... (cached) /usr/bin/xml2-config
            configure: error: xml2-config not found. Please check your libxml2 installation.
        2. 解决办法:
            1. 编译安装:libxml2-2.7.6.tar.gz
            2. php-5.5.31加入编译条件(目录根据自己前面编译libxml是写的目录):
                --enable-libxml --with-libxml-dir=/home/Qt/rootfs/busybox/php/libxml2-2.7.6
    2. 错误2:
        1. 错误现象:
            ......
            checking for strftime... (cached) yes
            checking which regex library to use... php
            checking whether to enable LIBXML support... yes
            checking libxml2 install dir... /home/Qt/rootfs/busybox/php/libxml2-2.7.6
            checking for xml2-config path... 
            configure: error: xml2-config not found. Please check your libxml2 installation.
        2. 解决办法:“
            sudo apt-get install libxml2-dev
    3. 错误3:
        1. 错误现象:
            ......
            checking whether to enable the SQLite3 extension... yes
            checking bundled sqlite3 library... yes
            checking for ZLIB support... yes
            checking if the location of ZLIB install directory is defined... no
            checking for zlib version >= 1.2.0.4... 1.2.3.4
            checking for gzgets in -lz... no
            configure: error: ZLIB extension requires gzgets in zlib
        2. 解决办法:
            1. 编译安装:zlib-1.2.8.tar.gz
            2. php-5.5.31加入编译条件(目录根据自己前面编译zlib是写的目录):
                --with-zlib --with-zlib-dir=/usr/local/php

六、matrix_gui 404 找不到index.html:
    1. 这可能是由于busybox的httpd默认识别的index.html,但我们的是index.php;
    2. 由上可知,我们需要在matrix_gui中指定我们需要访问的是index.php;
    3. 当然,我们也是可以在/etc/httpd.conf配置:
        I:index.php      # Show index.php when a directory is requested
    
七、总结:
    zlib最好要先于libxml2编译,同时在编译libxml2的时候将zlib的安装目录放置于PATH最前面。
原文地址:https://www.cnblogs.com/zengjfgit/p/5173465.html