移植 Nginx+PHP(FastCGI) 到 ARM Linux (一)
来源:互联网 发布:厦门大学网络教育报名 编辑:程序博客网 时间:2024/06/05 02:05
环境
交叉编译环境: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
Nginx 交叉编译
1、 预先下载好文件
a,nginx-1.12.1.tar.gz
b,pcre-8.30.tar.gz(不要下最新的pcre2-**.tar.gz)
c,zlib-1.2.11.tar.gz
说明:我这里不需要支持https访问,所以下面不会编译openssl模块。
2、 解压文件
robinson@robinson-vm:~/Downloads/ForTest$ lsnginx-1.12.1.tar.gz pcre-8.30.tar.gz zlib-1.2.11.tar.gzrobinson@robinson-vm:~/Downloads/ForTest$ tar -xzvf nginx-1.12.1.tar.gzrobinson@robinson-vm:~/Downloads/ForTest$ tar -xzvf pcre-8.30.tar.gzrobinson@robinson-vm:~/Downloads/ForTest$ tar -xzvf zlib-1.2.11.tar.gzrobinson@robinson-vm:~/Downloads/ForTest$ lsnginx-1.12.1 pcre-8.30 zlib-1.2.11nginx-1.12.1.tar.gz pcre-8.30.tar.gz zlib-1.2.11.tar.gz
3、 编写configure配置文件脚本nginx_configure.sh
#!/bin/shBUILD_PATH=/home/nginx_armCC_PATH=/home/robinson/Downloads/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf-gccCPP_PATH=/home/robinson/Downloads/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf-g++./configure \ --prefix=$BUILD_PATH \ --with-zlib=/home/robinson/Downloads/ForTest/zlib-1.2.11 \ --with-pcre \ --with-pcre=/home/robinson/Downloads/ForTest/pcre-8.30 \ --with-pcre-jit \ --with-cc=$CC_PATH \ --with-cpp=$CPP_PATH
说明:
此脚本文件存放于nginx-1.12.1文件夹下,需要自行添加可执行权限。
关于BUILD_PATH,这是编译好的nginx存放位置。
关于CC_PATH、CPP_PATH是交叉编译器路径,这里填的完整路径,如果配置好环境变量可以直接写:arm-linux-gnueabihf-gcc、arm-linux-gnueabihf-g++,大家需要根据自己的实际情况作调整。
前面提到了我没有配置openssl模块编译。
4、修改几处源代码(nginx-1.12.1文件夹下)
1). auto/cc/name
if [ "$NGX_PLATFORM" != win32 ]; thenngx_feature="C compiler"ngx_feature_name=#ngx_feature_run=yesngx_feature_run=no ==>set to no to skip checkngx_feature_incs=ngx_feature_path=
2). auto/types/sizeof
(1)ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS ==> ngx_test="gcc $CC_TEST_FLAGS $CC_AUX_FLAGS(2)checking for $ngx_type size END ngx_size= ==> ngx_size=4
3). auto/lib/pcre/make
./configure --disable-shared $PCRE_CONF_OPT ==>./configure --disable-shared $PCRE_CONF_OPT --host=arm
4). src/os/unix/ngx_errno.h
(新增)#define NGX_SYS_NERR 333(新增)#ifndef NGX_HAVE_SYSVSHM(新增)#define NGX_HAVE_SYSVSHM 1(新增)#endiftypedef int ngx_err_t;
5). src/core/ngx_rwlock.c
12行 #if (NGX_HAVE_ATOMIC_OPS) ==> #if (!NGX_HAVE_ATOMIC_OPS)
5、执行./nginx_configure.sh
robinson@robinson-vm:~/Downloads/ForTest/nginx-1.12.1$ sudo ./nginx_configure.shchecking for OS + Linux 3.13.0-32-generic x86_64checking for C compiler ... found + gcc version: 4.9.2 20140904 (prerelease) (crosstool-NG linaro-1.13.1-4.9-2014.09 - Linaro GCC 4.9-2014.09) checking for gcc -pipe switch ... foundchecking for -Wl,-E switch ... found*********************************************************checking for struct tm.tm_gmtoff ... foundchecking for struct dirent.d_namlen ... not foundchecking for struct dirent.d_type ... foundchecking for sysconf(_SC_NPROCESSORS_ONLN) ... foundchecking for openat(), fstatat() ... foundchecking for getaddrinfo() ... foundcreating objs/MakefileConfiguration summary + using PCRE library: /home/robinson/Downloads/ForTest/pcre-8.30 + OpenSSL library is not used + using zlib library: /home/robinson/Downloads/ForTest/zlib-1.2.11 nginx path prefix: "/home/nginx_arm" nginx binary file: "/home/nginx_arm/sbin/nginx" nginx modules path: "/home/nginx_arm/modules" nginx configuration prefix: "/home/nginx_arm/conf" nginx configuration file: "/home/nginx_arm/conf/nginx.conf" nginx pid file: "/home/nginx_arm/logs/nginx.pid" nginx error log file: "/home/nginx_arm/logs/error.log" nginx http access log file: "/home/nginx_arm/logs/access.log" nginx http client request body temporary files: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: "fastcgi_temp" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp"
6、make
robinson@robinson-vm:~/Downloads/ForTest/nginx-1.12.1$ sudo make
7、make install
robinson@robinson-vm:~/Downloads/ForTest/nginx-1.12.1$ sudo make install
生成的文件在/home/nginx_arm
8、打包交叉编译好的文件
robinson@robinson-vm:/home$ lsnginx_arm robinsonrobinson@robinson-vm:/home$ sudo tar -jcvf nginx_arm.tar.bz2 nginx_arm/nginx_arm/nginx_arm/html/nginx_arm/html/index.htmlnginx_arm/html/50x.htmlnginx_arm/logs/nginx_arm/sbin/nginx_arm/sbin/nginxnginx_arm/conf/nginx_arm/conf/fastcgi_params.defaultnginx_arm/conf/nginx.conf.defaultnginx_arm/conf/scgi_params.defaultnginx_arm/conf/nginx.confnginx_arm/conf/uwsgi_params.defaultnginx_arm/conf/fastcgi.confnginx_arm/conf/koi-utfnginx_arm/conf/mime.typesnginx_arm/conf/koi-winnginx_arm/conf/fastcgi.conf.defaultnginx_arm/conf/fastcgi_paramsnginx_arm/conf/mime.types.defaultnginx_arm/conf/uwsgi_paramsnginx_arm/conf/win-utfnginx_arm/conf/scgi_paramsrobinson@robinson-vm:/home$ lsnginx_arm nginx_arm.tar.bz2 robinson
9、将nginx_arm.tar.bz2拷贝到arm板子上,注意一定要在/home下解压(路径必须和交叉编译时的路径一致)
root@imx6dlsabresd:/home# lsnginx_arm root
10、启动nginx
root@imx6dlsabresd:/home/nginx_arm# /home/nginx_arm/sbin/nginx或root@imx6dlsabresd:/home/nginx_arm# /home/nginx_arm/sbin/nginx -c /home/nginx_arm/conf/nginx.conf
11、测试,用局域网内的浏览器访问Arm板子的ip,看到下面界面,说明nginx移植成功了。
后记
友情提示:
su命令会获取root权限但仍使用用户的环境变量。
sudo命令会获取root权限并使用root的环境变量。
- 移植 Nginx+PHP(FastCGI) 到 ARM Linux (一)
- 移植 Nginx+PHP(FastCGI) 到 ARM Linux (二)
- 移植 Nginx+PHP(FastCGI) 到 ARM Linux (三)
- lighttpd+php(fastcgi) 移植到arm-linux
- 移植nginx+php+sqlite到arm linux(一)
- 移植nginx+php+sqlite到arm linux(二)
- sqlite移植到arm(一)
- Linux下源码方式安装Nginx和PHP(FastCGI)
- arm linux fl2440 移植(一)
- sqlite3移植到arm linux
- sqlite3移植到arm-linux
- OpenCv 移植到Arm-linux
- Openssl移植到Arm linux
- 移植libmxml到(arm-linux)
- 移植tcpdump到arm linux
- canutils移植到ARM Linux
- 移植dhclient到arm linux
- udhcp移植到arm-linux
- Web安全笔记整理
- 实战6.SparkSQL(中)--深入了解SparkSQL运行计划及调优
- 复杂度
- iOS【开发即时通讯 SocketIO
- 实战6.SparkSQL(下)--Spark实战应用
- 移植 Nginx+PHP(FastCGI) 到 ARM Linux (一)
- 安卓behavior详解1--系统behavior的简单应用
- AOP和IOC
- 数据库三:浅谈数据库事务(transaction)
- 【Java概念】运算符(3)
- 各种hash算法合集
- 实战7.Spark Streaming(上)--Spark Streaming原理介绍
- 【每周论文】Quasar: Resource-Efficient and QoS-Aware Cluster Management
- VMware Workstation12|Mac OS X后怎么安装VMware Tools?