您的位置:首页 > 运维架构 > Nginx

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

2017-09-13 23:50 1086 查看

环境

交叉编译环境: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$ su
Password:
root@robinson-vm:/home/robinson/Downloads/php-5.6.31# ./simple_configure.sh

*****************
*****************
*****************
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes

creating libtool
appending configuration tag "CXX" to libtool

Generating files
configure: creating ./config.status
creating main/internal_functions.c
creating 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.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/cgi/php-cgi.1
config.status: creating main/php_config.h
config.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-cgi

Build complete.
Don't forget to run 'make test'.


7、make install

root@robinson-vm:/home/robinson/Downloads/php-5.6.31# make install
Installing 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-config
Installing 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  robinson
robinson@robinson-vm:/home$ sudo tar -jcvf php_arm.tar.bz2   php_arm/
robinson@robinson-vm:/home$ ls
nginx_arm  nginx_arm.tar.bz2  php_arm  php_arm.tar.bz2  robinson


9、将文件拷贝到ARM板子

root@imx6dlsabresd:/home# ls
Test  nginx_arm  php_arm.tar.bz2  root
root@imx6dlsabresd:/home# tar -xjvf php_arm.tar.bz2
root@imx6dlsabresd:/home# ls
Test  nginx_arm  php_arm  php_arm.tar.bz2  root


10、测试PHP

root@imx6dlsabresd:/home/php_arm/bin# ls
php  php-cgi  php-config  phpize  test.php

新建的test.php内容为:<?php echo "Hellor word!\n"; ?>

root@imx6dlsabresd:/home/php_arm/bin# ./php-cgi test.php
X-Powered-By: PHP/5.6.31
Content-type: text/html; charset=UTF-8

Hello word!
root@imx6dlsabresd:/home/php_arm/bin#


后记

友情提示:

su命令会获取root权限但仍使用用户的环境变量。

sudo命令会获取root权限并使用root的环境变量。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  arm php nginx linux