August 5, 2010

Cross Compile PHP 5.3.3 to ARM

Updated on 2012/05/08 for Compiling PHP 5.4.2  enabling FPM (fastcgi)

1. ./configure --host=arm-linux --without-pear --disable-simplexml --disable-mbregex --enable-sockets --enable-pdo --with-pdo-sqlite --with-sqlite3 --disable-all

2. vi Makefile, search for "-lcrypt", add "-ldl" to the same line.

3. make -j 12

4. php-cgi is in sapi/cgi.

5. use arm-linux-strip php-cgi to strip out the symbols

Done.

-- To compile PHP 5.4.2 with FPM enabled--


1. First edit the "configure" file to remove checking of ptrace and proc mem file (both should be set to yes, broken_ptrace set to no). If you don't need FPM, no change to configure script is necessary.

My new version of this section looks like this:


  have_broken_ptrace=no
  have_ptrace=yes
    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }


rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext


    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ptrace works" >&5
$as_echo_n "checking whether ptrace works... " >&6; }


      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }


rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
  conftest.$ac_objext conftest.beam conftest.$ac_ext




  if test "$have_ptrace" = "yes"; then


$as_echo "#define HAVE_PTRACE 1" >>confdefs.h


  fi


...



    proc_mem_file="mem"

  if test -n "$proc_mem_file" ; then
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for proc mem file" >&5
$as_echo_n "checking for proc mem file... " >&6; }

    if test "$cross_compiling" = no; then :
        { $as_echo "$as_me:${as_lineno-$LINENO}: result: $proc_mem_file" >&5
$as_echo "$proc_mem_file" >&6; }

rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
  conftest.$ac_objext conftest.beam conftest.$ac_ext
fi

  fi

2. CC=arm-none-linux-gnueabi-gcc ./configure --host=arm-linux --without-pear --disable-simplexml --disable-mbregex --enable-sockets --enable-pdo --with-pdo-sqlite --with-sqlite3 --enable-fpm --disable-all

3. make -j 12
4. php-fpm is at sapi/cgi
5. use arm-linux-strip php-fpm to strip out the symbols

Done.



10 comments:

  1. AWESOME! I can't compile php5.3.8 for arm linux 2 days, before found this page. Thx!

    ReplyDelete
  2. ¿Do you know if it is possible, to compile whitout --disable-all flag??

    ReplyDelete
  3. You can probably compile without the --disable-all flag, but you may run into some errors that you need to fix. You can --disable-all and then enable only the components you want.

    ReplyDelete
  4. can I use it with SQL and mini6410 ? thanks

    ReplyDelete
  5. I am pretty sure you can, but have not verified it.

    ReplyDelete

  6. during cross compilation of php5.5.4:


    ./configure --host=${CROSS_COMPILE} --target=arm -prefix=${ROOTDIR}/build --without-sqlite3 --without-pdo-sqlite --without-pear --enable-simplexml --disable-mbregex --enable-sockets --enable-fpm --disable-opcache --enable-libxml --without-zlib --with-iconv-dir=/home/tapan/libiconv-1.14/build/lib/ --with-libxml-dir=/home/tapan/libxml2-2.7.6/build/lib/

    checking for iconv support... yes
    checking for iconv... no
    checking for libiconv... no
    configure: error: Please reinstall the iconv library.

    ReplyDelete
  7. Hi,Tiebing,thanks a lot!
    Does php-cgi not have shared-memory functions,the message shows :
    Fatal error: Call to undefined function sem_get() in /usr/local/apache/htdocs/index.php on line 38

    can anyone help?

    Thank you.

    ReplyDelete
  8. Hi,Tiebing,thanks a lot!
    Does php-cgi not have shared-memory functions,the message shows :
    Fatal error: Call to undefined function sem_get() in /usr/local/apache/htdocs/index.php on line 38

    can anyone help?

    Thank you.

    ReplyDelete