移植nginx+php+sqlite到arm linux(一)

来源:互联网 发布:锐捷网络和星网锐捷 编辑:程序博客网 时间:2024/05/16 13:48

1.概述:

  经过一段时间的摸索,终于把Nginx+Php+Sqlite移植到ARM(Linux)的环境中并验证成功。
  虚拟机环境:ubuntu 10.04
  交叉编译器:arm-linux-gcc-4.5.x
  ARM硬件平台:ARM9
  ARM系统:linux 2.6.x
  由于篇幅较多,本篇文章只介绍nginx交叉编译和验证的部分。
 

2.交叉编译

交叉编译Nginx这一部分很大程度参考了这篇文章http://blog.csdn.net/xteda/article/details/49392223,但可能由于环境等其他方面的原因,有若干处未编译成功,最终使用了其他的方法解决了这些问题,如有错误欢迎批评指正。

2.1交叉编译PCRE库

下载地址:https://sourceforge.net/projects/pcre/files/pcre/8.30/
1.cp pcre-8.30.tar.gz /home/
2.cd /home/,tar -xvzf pcre-8.30.tar.gz
3.chmod -Rf 777 pcre-8.30
4.cd /home/pcre-8.30
5../configure –host=arm-none-linux-gnueabi –prefix=/home/nginx
//arm-none-linux-gnueabi根据具体情况自行替换
6.make
7.make install
8.最终我们需要的PCRE头文件和编译好的库文件在/home/nginx中

2.2交叉编译nginx

下载地址:http://mirrors.sohu.com/nginx/
1.cp nginx-1.0.15.tar.gz /home/,cd /home/
2.tar -xvzf nginx-1.0.15.tar.gz,chmod -Rf 777 nginx-1.0.15
3.cd nginx-1.0.15
4.打补丁
4.1/home/nginx-1.0.15/auto/cc/conf
这里写图片描述
修改为
这里写图片描述
换为arm平台的编译器工具
4.2/home/nginx-1.0.15/auto/types/sizeof
这里写图片描述
修改后
这里写图片描述

这里写图片描述
修改后
这里写图片描述
4.3/home/nginx-1.0.15/auto/feature
这里写图片描述
修改后
这里写图片描述
4.4/home/nginx-1.0.15/configure
这里写图片描述
修改后
这里写图片描述
4.5/home/nginx-1.0.15/src/os/unix/ngx_time.h
这里写图片描述
修改后
这里写图片描述
4.6/home/nginx-1.0.15/src/os/unix/ngx_errno.h
这里写图片描述
修改后
这里写图片描述
5.配置
export CC=arm-none-linux-gnueabi-gcc
export LD=arm-none-linux-gnueabi-ld
export AR=arm-none-linux-gnueabi-ar
export NGX_SYSTEM=linux
export NGX_RELEASE=3.2-XT6
export NGX_MACHINE=arm

这里需要注意的是nginx的configure不支持–host,所以要重置这些环境变量,这也会引起其他问题。

6../configure –with-google_perftools_module –with-http_stub_status_module –prefix=/home/nginx –with-pcre=/home/pcre-8.30 –with-cc-opt=”-O2 -Wall -Wpointer-arith -I/home/nginx/include” –with-ld-opt=”-L/home/nginx/lib”

报错:
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using –without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using –with-zlib= option.

zlib这个库我这次没有选择安装,交叉编译zlib可以参考下一篇文章。
7../configure –without-http_gzip_module –with-google_perftools_module –with-http_stub_status_module –prefix=/home/nginx –with-pcre=/home/pcre-8.30 –with-cc-opt=”-O2 -Wall -Wpointer-arith -I/home/nginx/include” –with-ld-opt=”-L/home/nginx/lib”

报错:
./configure: error: the Google perftool module requires the Google perftools library. You can either do not enable the module or install the library.

这里禁掉了google_perftools_module
8../configure –without-http_gzip_module –with-http_stub_status_module –prefix=/home/nginx –with-pcre=/home/pcre-8.30 –with-cc-opt=”-O2 -Wall -Wpointer-arith -I/home/include” –with-ld-opt=”-L/home/nginx/lib”

执行make报错:
checking whether we are cross compiling… configure: error: in /home/pcre-8.30:
configure: error: cannot run C compiled programs.
If you meant to cross compile, use –host.
See config.log for more details
make[1]: * [/home/pcre-8.30/Makefile] 错误 1
make[1]:正在离开目录 /home/nginx-1.0.15
make: * [build] 错误 2

cd /home/nginx-1.0.15/auto/lib/pcre
vim make
 
加一句–host=arm-none-linux-gnueabi
9.make clean
10.make
11.make install
我们需要的内容都在/home/nginx中包括可执行文件和依赖库。
12.压缩整个目录zip -ry ./nginx.zip ./nginx
13.在开发板的/home下解压(注意动态库的软连接)
14.
cd /etc 修改profile
export LD_LIBRARY_PATH=/lib:/usr/lib:/home/nginx/lib
source /etc/profile
15.完成nginx.conf的配置…(此步骤省略)
16./home/nginx/sbin/nginx -c /home/nginx/conf/nginx.conf -p /home/nginx 启动nginx

3.运行截图

这里写图片描述

0 0
原创粉丝点击