ARM交叉编译PHP

php+php 所需扩展库 交叉编译

安装依赖:

libxml2:

1.	wget ftp://xmlsoft.org/libxml2/libxml2-2.7.2.tar.gz
2.  tar xvf libxml2-2.7.2.tar.gz
3.  cd libxml2-2.7.2
4.  ./configure CC=aarch64-linux-gnu-gcc --host=aarch64-linux-gnu --prefix=/usr/local/libxml2 -without-python
5.  make && make install

报错如下:

1、configure: error: /bin/sh ./config.sub x86_64-unknown-linux-gnu failed
/usr/share/libtool/config/config.sub 与 /usr/share/libtool/config/config.guss 复制到要进行编译的目录
2、/usr/include/python2.7/pyconfig.h:45:35: fatal error: python2.7/pyconfig-64.h: No such file or directory 增加 -without-python 选项

zlib

1.wget http://www.zlib.net/fossils/zlib-1.2.9.tar.gz
2.tar -zxvf zlib-1.2.9.tar.gz
3.export CC=aarch64-linux-gnu-gcc
4./configure --prefix=install-dir
5.make && make install

安装PHP:

CC=aarch64-linux-gnu-gcc ./configure  --host=aarch64-linux-gnu --prefix=/usr/local/php  --with-libxml-dir=/usr/local/libxml2 --with-zlib-dir=/usr/local/zlib  --disable-all --enable-fpm --enable-hash --enable-json  --enable-session

如果要使用redis一定要将json、hash、session这三个拓展编译进去。

安装PHP拓展:

注:phpredis尽量不要用最新版本,至少跟你当前PHP版本兼容性强,否则会报错
以redis.so为例

1.wget http://pecl.php.net/get/redis-2.2.7.tgz
2.tar -xvf redis-2.2.7.tgz
3.cd redis-2.2.7.tgz
4./usr/local/php/bin/phpize 
5. ./configure CC=aarch64-linux-gnu-gcc --host=aarch64-linux-gnu --with-php-config=/usr/local/php/bin/php-config
6.make && make install

加载redis.so库

修改php.ini

extension_dir = "/usr/local/php5/lib/php/extensions/no-debug-non-zts-20131226/"                                                                      
extension="redis.so"  
posted @ 2020-11-11 17:48  如果云吃糖  阅读(1113)  评论(0编辑  收藏  举报