移植 Nginx+PHP(FastCGI) 到 ARM Linux (二)

来源:互联网 发布:javascript获取日期 编辑:程序博客网 时间:2024/05/16 03:24

环境

交叉编译环境:Ubuntu12.04 64位
交叉编译器:arm-linux-gcc-4.9.x
ARM系统:Linux imx6dlsabresd 3.14.52-1.1.1_ga+gdb1bcba #5 SMP PREEMPT Wed Mar 15 12:15:01 CST 2017 armv7l GNU/Linux

PHP 交叉编译

1、 预先下载好文件
a,php-5.6.31.tar.bz2

2、 解压文件

robinson@robinson-vm:~/Downloads tar -xjvf php-5.6.31.tar.bz2

4、 编写configure配置文件脚本simple_configure.sh,此文件存放于解压后的php-5.6.31文件夹下(最简易php编译)

#!/bin/sh./configure \  --prefix=/home/php_arm \  --host=arm-linux-gnueabihf \  --disable-all

如果需要添加个别模块,可自行在configure参数添加。如添加json模块

#!/bin/sh./configure \  --prefix=/home/php_arm \  --host=arm-linux-gnueabihf \  --disable-all \  --enable-json

5、运行脚本./simple_configure.sh

robinson@robinson-vm:~/Downloads/php-5.6.31$ suPassword: root@robinson-vm:/home/robinson/Downloads/php-5.6.31# ./simple_configure.sh***************************************************checking how to hardcode library paths into programs... immediatechecking whether stripping libraries is possible... yeschecking if libtool supports shared libraries... yeschecking whether to build shared libraries... nochecking whether to build static libraries... yescreating libtoolappending configuration tag "CXX" to libtoolGenerating filesconfigure: creating ./config.statuscreating main/internal_functions.ccreating main/internal_functions_cli.c+--------------------------------------------------------------------+| License:                                                           || This software is subject to the PHP License, available in this     || distribution in the file LICENSE.  By continuing this installation || process, you are bound by the terms of this license agreement.     || If you do not agree with the terms of this license, you must abort || the installation process at this point.                            |+--------------------------------------------------------------------+Thank you for using PHP.config.status: creating php5.specconfig.status: creating main/build-defs.hconfig.status: creating scripts/phpizeconfig.status: creating scripts/man1/phpize.1config.status: creating scripts/php-configconfig.status: creating scripts/man1/php-config.1config.status: creating sapi/cli/php.1config.status: creating sapi/cgi/php-cgi.1config.status: creating main/php_config.hconfig.status: executing default commands错误1:checking whether libxml build works... no解决1: sudo apt-get install libxml2-dev

6、make

root@robinson-vm:/home/robinson/Downloads/php-5.6.31# make***********************Zend/zend_virtual_cwd.lo Zend/zend_ast.lo Zend/zend_objects.lo Zend/zend_object_handlers.lo Zend/zend_objects_API.lo Zend/zend_default_classes.lo Zend/zend_execute.lo main/internal_functions_cli.lo sapi/cgi/cgi_main.lo sapi/cgi/fastcgi.lo -lcrypt -lcrypt -lm -lcrypt -lcrypt  -o sapi/cgi/php-cgiBuild complete.Don't forget to run 'make test'.

7、make install

root@robinson-vm:/home/robinson/Downloads/php-5.6.31# make installInstalling PHP CLI binary:        /home/php_arm/bin/Installing PHP CLI man page:      /home/php_arm/php/man/man1/Installing PHP CGI binary:        /home/php_arm/bin/Installing PHP CGI man page:      /home/php_arm/php/man/man1/Installing build environment:     /home/php_arm/lib/php/build/Installing header files:           /home/php_arm/include/php/Installing helper programs:       /home/php_arm/bin/  program: phpize  program: php-configInstalling man pages:             /home/php_arm/php/man/man1/  page: phpize.1  page: php-config.1

8、打包交叉编译好的文件

robinson@robinson-vm:~/Downloads/php-5.6.31$ ls /home/nginx_arm  nginx_arm.tar.bz2  php_arm  robinsonrobinson@robinson-vm:/home$ sudo tar -jcvf php_arm.tar.bz2   php_arm/robinson@robinson-vm:/home$ lsnginx_arm  nginx_arm.tar.bz2  php_arm  php_arm.tar.bz2  robinson

9、将文件拷贝到ARM板子

root@imx6dlsabresd:/home# lsTest  nginx_arm  php_arm.tar.bz2  rootroot@imx6dlsabresd:/home# tar -xjvf php_arm.tar.bz2root@imx6dlsabresd:/home# lsTest  nginx_arm  php_arm  php_arm.tar.bz2  root

10、测试PHP

root@imx6dlsabresd:/home/php_arm/bin# lsphp  php-cgi  php-config  phpize  test.php新建的test.php内容为:<?php echo "Hellor word!\n"; ?>root@imx6dlsabresd:/home/php_arm/bin# ./php-cgi test.phpX-Powered-By: PHP/5.6.31Content-type: text/html; charset=UTF-8Hello word!root@imx6dlsabresd:/home/php_arm/bin#

后记

友情提示:
su命令会获取root权限但仍使用用户的环境变量。
sudo命令会获取root权限并使用root的环境变量。

原创粉丝点击