交叉编译php5,、nginx、squid方法
本文为原创,转载请注明:http://www.cnblogs.com/tolimit/
交叉编译php5
软件版本:php-5.4.27
依赖库:zlib,libxml2
交叉编译器:arm-hisiv200-linux-gnueabi
- 将交叉编译器路径添加到PATH中, 我的交叉编译器目录为/usr/local/arm-hisiv200-linux/,而交叉编译器在交叉编译器目录的/bin中,在控制台输入
PATH=$PATH:/usr/local/arm-hisiv200-linux/bin/
- 首先先交叉编译zlib,进入zlib源码目录。
- 执行CC=arm-hisiv200-linux-gnueabi-gcc ./configure --shared --prefix=ZLIB_PATH(编译成功后的安装路径)
- make && make install
- 在ZLIB_PATH中会有编译成功后的文件和配置。
- 然后交叉编译libxml2,进入libxml2源码目录。
- 执行CC=arm-hisiv200-linux-gnueabi-gcc ./configure --host=arm-hisiv200-linux-gnueabi --prefix=LIBXML2_PATH(编译成功后的安装路径)
- make && make install
- 在LIBXML2_PATH中会有编译成功后的文件和配置。
- 开始交叉编译php5,进入php5源码目录。
- 首先先执行./buildconf --force,为了防止出现 cp:cannot stat 'sapi/cli/php.1': No such file or directory
- 执行./configure --host=arm-hisiv200-linux-gnueabi --enable-shared --with-zlib-dir=ZLIB_PATH --with-libxml-dir=LIBXML2_PATH --disable-phar --with-sqlite --with-pdo-sqlite --without-iconv --enable-fpm --prefix=PHP5_PATH
- make && make install
- 编译好的php程序及配置就在PHP5_PATH中。
交叉编译nginx
软件版本:nginx-1.6.2
依赖源码:pcre,zlib(这里是需要用到它们的源码)
交叉编译器:arm-hisiv200-linux-gnueabi
linux版本:32位ubuntu(这个很重要,主要是使用32位x86系统才能进行编译成功,因为字长不一样)
交叉编译nginx与交叉编译php5不同就是nginx用的是依赖的库的源码,而php5用的是库文件。
- 进入nginx-1.6.2源码目录。
- 在配置和编译nginx会出现很多错误,我们一个一个解决,首先我使用的configure配置如下:
#!/bin/bash CC_PATH=/home/shanlink/Cross_compile/arm-hisiv200-linux/bin/arm-hisiv200-linux-gnueabi-gcc
CPP_PATH=/home/shanlink/Cross_compile/arm-hisiv200-linux/bin/arm-hisiv200-linux-gnueabi-g++
INSTALL_PATH=/home/shanlink/Cross_compile/nginx_ccs/
PCRE_PATH=/home/shanlink/Cross_compile/pcre-8.11/
ZLIB_PATH=/home/shanlink/Cross_compile/zlib-1.2./
CC_OPTS="-I /home/shanlink/Cross_compile/arm-hisiv200-linux/target/include/" ./configure --prefix=$INSTALL_PATH --with-zlib=$ZLIB_PATH --with-pcre=$PCRE_PATH --with-cc=$CC_PATH --with-cpp=$CPP_PATH --with-cc-opt=$CC_POTS --with-ld-opt="-L /home/shanlink/Cross_compile/arm-hisiv200-linux/target/lib/" - 好的,把以上内容做成一个运行脚本,运行,出现一个错误:
checking for OS
+ Linux 3.13.--generic x86_64
checking for C compiler ... found but is not working ./configure: error: C compiler /home/shanlink/Cross_compile/arm-hisiv200-linux/bin/arm-hisiv200-linux-gnueabi-gcc is not found解决办法就是:编辑auto/cc/name文件,在文件开头有如下一段,注释掉exit 1
if [ "$NGX_PLATFORM" != win32 ]; then ngx_feature="C compiler"
ngx_feature_name=
ngx_feature_run=yes
ngx_feature_incs=
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test=
. auto/feature if [ $ngx_found = no ]; then
echo
echo $: error: C compiler $CC is not found
echo
#exit 注释掉这一行
fi fi - 再次运行我们的配置脚本,这时候出现
checking for TCP_INFO ... found
checking for accept4() ... found
checking for int size ...objs/autotest: : objs/autotest: Syntax error: word unexpected (expecting ")")
bytes ./configure: error: can not detect int size
cat: objs/autotest.c: No such file or directory解决方法:编辑auto/types/sizeof文件,找到
ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \
-o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs" 将的$CC改为x86上使用的gcc ngx_test="gcc $CC_TEST_FLAGS $CC_AUX_FLAGS \
-o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs" - 再次运行我们的配置脚本,这时应该可以顺利配置完成。
- 执行make,这时候会出现一个错误
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/home/shanlink/Cross_compile/pcre-8.11':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details.
make[]: *** [/home/shanlink/Cross_compile/pcre-8.11//Makefile] Error 1
make[]: Leaving directory `/home/shanlink/Cross_compile/nginx-1.6.'
make: *** [build] Error这个是由于nginx在编译时会同时配置pcre并且进行编译,而由于是交叉编译,pcre的配置时需要添加--host=arm-hisiv200-linux-gnueabi,因为是由nginx自动配置的,所以我们需要手动添加此选项于pcre,然后再make,此选项添加在
文件:objs/Makefile 找到如下一段:
/home/shanlink/Cross_compile/pcre-8.11//Makefile: objs/Makefile
cd /home/shanlink/Cross_compile/pcre-8.11/ \
&& if [ -f Makefile ]; then $(MAKE) distclean; fi \
&& CC="$(CC)" CFLAGS="-O2 -fomit-frame-pointer -pipe " \
./configure --disable-shared 将
./configure --disable-shared
改为
./configure --disable-shared --host=arm-hisiv200-linux-gnueabi(这个交叉编译器前缀填你们电脑上自己的) - 如果遇到一下错误,原因是你们的linux系统是64位的,而arm上一般都是32位的,所以会有这个错误,解决办法就是重新装一个32位的linux系统。
src/core/ngx_slab.c: In function 'ngx_slab_alloc_locked':
src/core/ngx_slab.c:: error: integer constant is too large for 'long' type
src/core/ngx_slab.c:: error: comparison is always true due to limited range of data type
src/core/ngx_slab.c:: error: integer constant is too large for 'long' type
src/core/ngx_slab.c:: error: comparison is always false due to limited range of data type
src/core/ngx_slab.c:: error: integer constant is too large for 'long' type
src/core/ngx_slab.c:: error: comparison is always true due to limited range of data type
src/core/ngx_slab.c:: error: integer constant is too large for 'long' type
src/core/ngx_slab.c:: error: comparison is always true due to limited range of data type
src/core/ngx_slab.c:: error: integer constant is too large for 'long' type
src/core/ngx_slab.c:: error: comparison is always false due to limited range of data type
src/core/ngx_slab.c:: error: left shift count >= width of type
src/core/ngx_slab.c:: error: integer constant is too large for 'long' type
src/core/ngx_slab.c:: error: left shift count >= width of type
src/core/ngx_slab.c:: error: integer constant is too large for 'long' type
src/core/ngx_slab.c:: error: left shift count >= width of type
src/core/ngx_slab.c: In function 'ngx_slab_free_locked':
src/core/ngx_slab.c:: error: integer constant is too large for 'long' type
src/core/ngx_slab.c:: error: comparison is always false due to limited range of data type
src/core/ngx_slab.c:: error: integer constant is too large for 'long' type
src/core/ngx_slab.c:: error: integer constant is too large for 'long' type
src/core/ngx_slab.c:: error: comparison is always false due to limited range of data type
src/core/ngx_slab.c:: error: integer constant is too large for 'long' type
src/core/ngx_slab.c: In function 'ngx_slab_alloc_pages':
src/core/ngx_slab.c:: error: integer constant is too large for 'long' type
src/core/ngx_slab.c:: error: integer constant is too large for 'long' type
src/core/ngx_slab.c:: error: large integer implicitly truncated to unsigned type
make[]: *** [objs/src/core/ngx_slab.o] Error
make[]: Leaving directory `/home/shanlink/Cross_compile/nginx-1.6.'
make: *** [build] Error - 这时候继续make,还会出现两个错误,一个是
src/os/unix/ngx_errno.c: In function 'ngx_strerror':
src/os/unix/ngx_errno.c:: error: 'NGX_SYS_NERR' undeclared (first use in this function)
src/os/unix/ngx_errno.c:: error: (Each undeclared identifier is reported only once
src/os/unix/ngx_errno.c:: error: for each function it appears in.)
src/os/unix/ngx_errno.c: In function 'ngx_strerror_init':
src/os/unix/ngx_errno.c:: error: 'NGX_SYS_NERR' undeclared (first use in this function)
make[]: *** [objs/src/os/unix/ngx_errno.o] Error
make[]: Leaving directory `/home/shanlink/Cross_compile/nginx-1.6.'
make: *** [build] Error解决方法就是打开objs/ngx_auto_config.h,添加
#ifndef NGX_SYS_NERR
#define NGX_SYS_NERR 132
#endif另一个错误
objs/src/event/ngx_event_accept.o: In function `ngx_event_accept':
/home/shanlink/Cross_compile/nginx-1.6./src/event/ngx_event_accept.c:: warning: warning: accept4 is not implemented and will always fail
objs/src/core/ngx_cycle.o: In function `ngx_init_cycle':
/home/shanlink/Cross_compile/nginx-1.6./src/core/ngx_cycle.c:: undefined reference to `ngx_shm_free'
/home/shanlink/Cross_compile/nginx-1.6./src/core/ngx_cycle.c:: undefined reference to `ngx_shm_alloc'
/home/shanlink/Cross_compile/nginx-1.6./src/core/ngx_cycle.c:: undefined reference to `ngx_shm_free'
objs/src/event/ngx_event.o: In function `ngx_event_module_init':
/home/shanlink/Cross_compile/nginx-1.6./src/event/ngx_event.c:: undefined reference to `ngx_shm_alloc'
collect2: ld returned exit status
make[]: *** [objs/nginx] Error
make[]: Leaving directory `/home/shanlink/Cross_compile/nginx-1.6.'
make: *** [build] Error
shanlink@ubuntu:~/Cross_compile同样的,我们需要修改objs/ngx_auto_config.h文件,在文件中加入
#ifndef NGX_HAVE_SYSVSHM
#define NGX_HAVE_SYSVSHM 1
#endif - 好了,这时候make && make install就应该能编译过去了。
- 如果遇到其他编译问题,请参考:http://blog.csdn.net/fish43237/article/details/40515897
交叉编译squid
软件版本:squid-2.7-STABLE9
交叉编译器:arm-hisiv200-linux-gnueabi
系统:32位ubuntu
在对squid进行交叉编译时,需要用到x86版本的squid,所以我们要进行两个版本的编译。
- 首先编译x86版本的使用配置为
./configure --prefix=X86_SQUID_PATH
- make && make install
- 进入到squid源码目录下的src/文件夹,有个cf_gen程序,备份起来,交叉编译时会用到。
- 建立一个arm-linux.cache文件,写入
ac_cv_epoll_works=
ac_cv_af_unix_large_dgram=
ac_cv_func_setresuid=
ac_cv_func_va_copy=
ac_cv_func___va_copy= - 执行
#!/bin/bash ./configure --host=arm-hisiv200-linux-gnueabi --prefix=/home/shanlink/Cross_compile/squid_ccs/ --cache-file=arm-linux.cache
这时应该是能够顺利通过的
- 执行make,会出现一个错误
./cf_gen: cannot execute binary file
- 将之前备份的x86的cf_gen复制到src/目录下替换arm的
- 再次执行make,应该可以顺利通过编译
- make install
- 完成
交叉编译php5,、nginx、squid方法的更多相关文章
- centos7 下 apache nginx squid https正向代理 代理服务器
apache yum install httpd mod_ssl -y vim /etc/httpd/conf.d/ssl.conf Listen https <VirtualHost *:&g ...
- <亲测>CentOS7中使用yum安装Nginx的方法
CentOS7中使用yum安装Nginx的方法 最近无意间发现Nginx官方提供了Yum源.因此写个文章记录下. 1.添加源 默认情况Centos7中无Nginx的源,最近发现Nginx官网提供了 ...
- 搭建自己的代理服务 proxy nginx squid ss5 s(shadow)s(socks)
标签: nginx / squid / 负载均衡 / ss 4090 1. nginx (forward) nginx自己熟悉,经常用来做负载均衡的反向代理, 这里搭建一个正向代理(forward) ...
- CentOS 6.5安装配置LAMP服务器(Apache+PHP5+MySQL)的方法
CentOS 6.5安装配置LAMP服务器(Apache+PHP5+MySQL)的方法 准备篇: 1.配置防火墙,开启80端口.3306端口vi /etc/sysconfig/iptables-A I ...
- Centos上Apache重启,mysql重启,nginx重启方法
转载:http://www.3lian.com/edu/2012/04-01/24278.html Centos上Apache重启,mysql重启, nginx 重启方法 1.重启 apache se ...
- PHP5中魔术方法
魔术函数 1.__construct() 实例化对象时被调用, 当__construct和以类名为函数名的函数同时存在时,__construct将被调用,另一个不被调用. 2.__destruct() ...
- CI框架 CodeIgniter 伪静态 htaccess设置和Nginx伪静态方法
众所周知,LAMP代表Linux下Apache.MySQL.PHP这种网站服务器架构:而LNMP指的是Linux下Nginx.MySQL.PHP这种网站服务器架构.LNMP一键安装包可以从网上下载使用 ...
- nginx配置方法
nginx配置的代码: user www www; worker_processes 8; error_log /data111/logs/nginx/nginx-error.log crit; pi ...
- CentOS 7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14方法分享
一.配置防火墙,开启80端口.3306端口 CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop fi ...
随机推荐
- Mininet建立topology zoo中的拓扑
以前用Mininet建立拓扑都是在别人的代码上进行需求上的修改,这次从头开始将topology zoo(http://www.topology-zoo.org/)中的拓扑用Mininet建立,不失一般 ...
- css兼容性的问题
https://www.douban.com/note/314793848/ 随意的一个博客ie6的兼容 这个博客比较好 http://blog.csdn.net/chuyuqing/article/ ...
- OWIN-WebAPI-Windows Service
tks: https://github.com/danesparza/OWIN-WebAPI-Service add 2015 0717:http://kb.cnblogs.com/page/5092 ...
- 15.C#回顾及匿名类型(八章8.1-8.5)
今天的篇幅应该会很长,除了回顾前面学的一些,还有写一些关于匿名类型的相关知识,总体上对后续的学习很有帮助,学好了,后面更容易理解,不明白的,那就前面多翻几次,看多了总是会理解的.那么,进入正题吧. 自 ...
- JS事件学习笔记(思维导图)
导图
- java中的字符串简介,字符串的优化以及如何高效率的使用字符串
简介 String最为java中最重要的数据类型.字符串是软件开发中最重要的对象之一,通常,字符串对象在内存中总是占据着最大的空间块.所以,高效处理字符串,将提高系统的整个性能. 在java语言中,S ...
- ES6 你可能不知道的事 – 基础篇
序 ES6,或许应该叫 ES2015(2015 年 6 月正式发布),对于大多数前端同学都不陌生. 首先这篇文章不是工具书,不会去过多谈概念,而是想聊聊关于每个特性 你可能不知道的事,希望能为各位同学 ...
- 【bzoj2463】 谁能赢呢?
www.lydsy.com/JudgeOnline/problem.php?id=2463 (题目链接) 题意 一个n*n的棋盘,开始时左上角有一个棋子,每次可以把棋子向4个方向移动,但不能移动到曾经 ...
- POJ3579 Median
Description Given N numbers, X1, X2, ... , XN, let us calculate the difference of every pair of numb ...
- 记录一次MVC 3.0错误 HTTP 404您正在查找的资源(或者它的一个依赖项)可能已被移除,或其名称已更改,或暂时不可用。请检查以下 URL 并确保其拼写正确。
在部署到IIS7时,MVC3报了一个找不到资源的错误,文件肯定是有的,而且页面是肯定报错的,也就说内部运行错误了,而MVC把错误没有抛出来而已: 所以对症下药,发觉我的项目里面用了rexs进行多语言, ...