Compile minimal PHP for Workerman
编译支持 Workerman 框架的最小php

成果:

root@debian:/home/php/7.0.15/i386/bin# ./php -v
PHP 7.0.15 (cli) (built: Feb 10 2017 19:21:00) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
root@debian:/home/php/7.0.15/i386/bin# ./php -m
[PHP Modules]
Core
curl
date
json
pcntl
pcre
posix
Reflection
session
SPL
standard

系统: Debian 8 jessie 首先安装编译依赖

apt install build-essential libcurl4-gnutls-dev

下载源码,解压

cd ~
wget http://hk1.php.net/distributions/php-7.0.15.tar.gz
tar zxvf php-7.0.15.tar.gz
cd php-7.0.15
./configure \
--prefix=/home/php/7.0.15/i386 \
--disable-all \
--enable-json \
--enable-posix \
--enable-pcntl \
--enable-session \
--disable-cgi \
--with-curl \
--disable-phpdbg

如果需要交叉编译,只需添加 --host=target 即可。 例如:--host=arm-brcm-linux-uclibcgnueabi target可使用 gcc -v 查看。

root@crazy:~# arm-brcm-linux-uclibcgnueabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-brcm-linux-uclibcgnueabi-gcc
COLLECT_LTO_WRAPPER=/projects/hnd/tools/linux/hndtools-arm-linux-2.6.36-uclibc-4.5.3/libexec/gcc/arm-brcm-linux-uclibcgnueabi/4.5.3/lto-wrapper
Target: arm-brcm-linux-uclibcgnueabi
Configured with: /projects/toolchains_build/buildroot-2012.02-brcm/output/toolchain/gcc-4.5.3/configure
...
Thread model: posix
gcc version 4.5.3 (Buildroot 2012.02)
root@crazy:~# aarch64-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=aarch64-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/aarch64-linux-gnu/5/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v
...
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.4) 

编译,安装

root@debian:~/php-7.0.15# time make -j2
...
Build complete.
Dont forget to run make test.


real    11m16.413s
user    18m29.920s
sys     0m54.328s
root@debian:~/php-7.0.15# make install
root@debian:~/php-7.0.15# cd /home/php/7.0.15/i386/bin
root@debian:/home/php/7.0.15/i386/bin# ls -l -h
total 26M
-rwxr-xr-x 1 root root  13M Feb 10 19:29 php
-rwxr-xr-x 1 root root 2.3K Feb 10 19:30 php-config
-rwxr-xr-x 1 root root  13M Feb 10 19:29 phpdbg
-rwxr-xr-x 1 root root 4.5K Feb 10 19:30 phpize

最后修改于 Fri, 10 Feb 2017