需要准备的东西:

Apache-1.3.39 for linux

Php-4.4.8 for linux

Ubuntu amd64位 PC机

6410开发板,我用的是友善之臂

交叉编译:

交叉编译呢,简单地说,就是在一个平台上生成另一个平台上的可执行代码,即使用pc上的arm linuxgcc编译器编译好代码,并安装,然后把整个安装包放到开发板的相应目录。

理论上只需在PC上编译安装arm版的apache和php即可,实际上由于在编译安装过程中需要用到某些文件,而这些文件在x86或amd64平台上无法运行的,所以在编译arm版的apache和php之前,需要先使用gcc编译x86版的apache和php。

Apache和php安装包放在/usr/local上,并且arm版的安装在apache_arm文件夹,x86版的安装在apache_test文件夹

编译安装apache

本地x86编译:

tar xvf apache_1.3.39.tar.gz

cd /usr/local/apache_1.3.39/

./configure --prefix=/usr/local/apache_test/apache --enable-module=so

出现:

Syntax error — The configuration file is used only to
define the list of included modules or to set Makefile in src
options or Configure rules, and I don’t see that at all:
`$(SRCDIR)/apaci`
default
default
no
no
no
yes
no
default
no
default
default

这是由于某些shell脚本文件使用了错误的interpreter,使用下面的命令就可以解决。

# rm -f /bin/sh
# ln -s /bin/bash /bin/sh

再次./configure,没问题

接着make

出错:

htpasswd.c:101:12: error: conflicting types for ‘getline’

static int getline(char *s, int n, FILE *f)

^

In file included from ../include/ap_config.h:1054:0,

from htpasswd.c:40:

/usr/include/stdio.h:678:20: note: previous declaration of ‘getline’ was here

extern _IO_ssize_t getline (char **__restrict __lineptr,

^

make[2]: *** [htpasswd.o] Error 1

make[2]: Leaving directory `/usr/local/apache_1.3.39/src/support'

make[1]: *** [build-support] Error 1

make[1]: Leaving directory `/usr/local/apache_1.3.39'

make: *** [build] Error 2

解决方法:

这个问题是apache里自带了一个getline函数,并和stdio.h里的getline函数冲突了

gedit gedit /usr/include/stdio.h

找到getlline函数,把名字替换成parseline,保存,再make,ok,编译成功,然后记得把parseline函数改回getline

Make install也没有问题

注:(这里必须要注意:事实上,我花了将近一个星期的时间去移植,第一次移植时我是老老实实去make install了,结果在最后,我在pc上运行arm版的apache时竟然不报错,这是有问题的,因为arm linux gcc编译过的运行文件是不能在x86平台上跑的,而且x86和arm的apache能互相start和stop,由此断定肯定是安装出错了, 无奈下我全把所有安装文件全删了,重新再来一遍,但我把x86 的apache安装包备份了,事实上,x86 的apache里面有一个httpd文件在安装arm的php时需要用到,由此建议make install后把安装包备份,然后删掉)

Arm编译:

新建一个文件夹,用来存放apache for arm

mkdir  /usr/local/apache_1.3.39_arm

tar xvf apache_1.3.39.tar.gz -C apache_1.3.39_arm

cd /usr/local/apache_1.3.39_arm/apache_1.3.39

CC=arm-linux-gcc ./configure --prefix=/usr/local/apache_arm/apache --enable-module=so

出错:

提示testfunc不能打开二进制文件,因为交叉编译的生成的testfunc这个工具不能在PC上执行,可以不理会它。

接着修改一个配置文件,使用上面pc机编译过的文件,

打开/usr/local/apache_1.3.39_arm/apache_1.3.39/src/main/Makefile这个文件,找 到 这 两 段 代 码

uri_delims.h

: gen_uri_delims

./gen_uri_delims >uri_delims.h

test_char.h

: gen_test_char

./gen_test_char >test_char.h

修改为

uri_delims.h: gen_uri_delims

/usr/local/apache_1.3.39/src/main/gen_uri_delims >uri_delims.h

test_char.h: gen_test_char

/usr/local/apache_1.3.39/src/main/gen_test_char >test_char.h

这里借用了刚才编译生成的本机代码里的工具

Make,出错,修改arm-linux-gcc里的stdio.h,找到getlline函数,把名字替换成parseline,保存,再make,ok,编译成功

再make install ,没问题了,然后记得把parseline函数改回getline

这样,apache for arm就安装结束了,将apache_arm打包到开发板的/usr/local,运行,应该是没有问题了。

PHP编译安装(保证apache没有问题的前提下):

X86版:

cd /usr/llocal

tar -jxvf php-4.4.8.tar.bz2

cd ./php-4.4.8/

./configure

出错:

configure: error: cannot find output from lex; giving up

apt-get install flex

再次./configure,可以了,make,也没有问题

ARM版:

cd /usr/llocal

mkdir /usr/local/php-4.4.8_arm

tar -jxvf php-4.4.8.tar.bz2 -C php-4.4.8_arm

cd ./php-4.4.8_arm/php-4.4.8

CC=arm-linux-gcc ./configure  --prefix=/usr/local/apache_arm/php --with-apxs=/usr/local/apache_arm/apache/bin/apxs

报错:

Sorry, I was not able to successfully run APXS.  Possible reasons:

1.  Perl is not installed;

2.  Apache was not compiled with DSO support (--enable-module=so);

3.  'apxs' is not in your path.  Try to use --with-apxs=/path/to/apxs

The output of /usr/local/apache-arm11/apache/bin/apxs follows

Use of assignment to $[ is deprecated at /usr/local/apache-arm11/apache/bin/apxs line 86.

/usr/local/apache-arm11/apache/bin/httpd: /usr/local/apache-arm11/apache/bin/httpd: cannot execute binary file

apxs:Error: Sorry, no DSO support for Apache available

apxs:Error: under your platform. Make sure the Apache

apxs:Error: module mod_so is compiled into your server

apxs:Error: binary `/usr/local/apache-arm11/apache/bin/httpd'.

configure: error: Aborting

解决方法:

在/usr/local/php-4.4.8_arm/php-4.4.8/configure找到checking for Apache 1.x module support via DSO through APXS,把下面的代码注释掉

#  $APXS -q CFLAGS >/dev/null 2>&1

#  if test "$?" != "0"; then

#    echo "$ac_t""" 1>&6

#    echo "$ac_t""" 1>&6

#    echo "$ac_t""Sorry, I was not able to successfully run APXS.  Possible reasons:" 1>&6

#    echo "$ac_t""" 1>&6

#    echo "$ac_t""1.  Perl is not installed;" 1>&6

#    echo "$ac_t""2.  Apache was not compiled with DSO support (--enable-module=so);" 1>&6

#    echo "$ac_t""3.  'apxs' is not in your path.  Try to use --with-apxs=/path/to/apxs" 1>&6

#    echo "$ac_t""The output of $APXS follows" 1>&6

#    $APXS -q CFLAGS

#    { echo "configure: error: Aborting" 1>&2; exit 1; }

#  fi

搜索“can not run test program while cross compiling”,会搜索到很多个这样的结果:
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
把它们都改为
{ echo "configure: error: can not run test program while cross compiling" 1>&2; }
这样做的目的是直接无视交叉编译测试程序错误。

./config没问题了

Make

出错:

In file included from /usr/local/php-4.4.8-arm/php-4.4.8/sapi/apache/sapi_apache.c:24:0:

/usr/local/php-4.4.8-arm/php-4.4.8/sapi/apache/php_apache_http.h:22:19: fatal error: httpd.h: No such file or directory

compilation terminated.

make: *** [sapi/apache/sapi_apache.lo] Error 1

解决方法:

使用PC机编译的PHP文件

gedit /usr/local/php-4.4.8_arm/php-4.4.8/Makefile

install-pear-packages: $(top_builddir)/sapi/cli/php

@$(top_builddir)/sapi/cli/php $(PEAR_INSTALL_FLAGS) /usr/local/php-4.4.8-arm/php-4.4.8/pear/install-pear.php -d "$(peardir)" -b "$(bindir)" /usr/local/php-4.4.8-arm/php-4.4.8/pear/packages/*.tar

修改为:

: /usr/local/php-4.4.8/sapi/cli/php

@/usr/local/php-4.4.8/sapi/cli/php $(PEAR_INSTALL_FLAGS) /usr/local/php-4.4.8-arm/php-4.4.8/pear/install-pear.php -d "$(peardir)" -b "$(bindir)" /usr/local/php-4.4.8-arm/php-4.4.8/pear/packages/*.tar

并修改相应头文件的绝对路径,不然会提示某些头文件找不到

gedit /usr/local/php-4.4.8_arm/php-4.4.8/sapi/apache/mod_php4.c

#include "/usr/local/apache-arm11/apache/include/http_conf_globals.h"

gedit /usr/local/php-4.4.8_arm/php-4.4.8/sapi/apache/php_apache_http.h

#include "/usr/local/apache_arm/apache/include/httpd.h"

#include "/usr/local/apache_arm/apache/include/http_config.h"

# include "/usr/local/apache_arm/apache/include/ap_compat.h"

#include "/usr/local/apache_arm/apache/include/http_core.h"

#include "/usr/local/apache_arm/apache/include/http_main.h"

#include "/usr/local/apache_arm/apache/include/http_protocol.h"

#include "/usr/local/apache_arm/apache/include/http_request.h"

#include "/usr/local/apache_arm/apache/include/http_log.h"

#include "/usr/local/apache_arm/apache/include/util_script.h"

反正是缺什么补什么,那些头文件都在/usr/local/apache_arm/apache/include里

Make终于可以了:如下

Build complete.

(It is safe to ignore warnings about tempnam and tmpnam).

Make install

出错:

root@Da:/usr/local/php-4.4.8_arm/php-4.4.8# make install

Installing PHP SAPI module:       apache

Use of assignment to $[ is deprecated at /usr/local/apache_arm/apache/bin/apxs line 86.

/usr/local/apache_arm/apache/bin/httpd: /usr/local/apache_arm/apache/bin/httpd: cannot execute binary file

apxs:Error: Sorry, no DSO support for Apache available

apxs:Error: under your platform. Make sure the Apache

apxs:Error: module mod_so is compiled into your server

apxs:Error: binary `/usr/local/apache_arm/apache/bin/httpd'.

make: *** [install-sapi] Error 1

apache_arm/apache/bin/httpd是运行在arm平台上的,当然不能在x86上跑,明白这点,果断把一开始安装的x86 apache的httpd拷贝过来,不要忘记,备份好arm的httpd,安装完后还要覆盖回来,我当初就是由于忘了覆盖回来,打包好的安装文件在6410上运行,结果报错如下:

输入/usr/local/apache-arm11/apache/bin/apachectl start

报错:

/usr/local/apache_arm/apache/bin/httpd: line1: elf: not found

/usr/local/apache_arm/apache/bin/httpd: line2: syntax error: unexpected ”(”

明显,这个是x86的httpd当然也不能在arm平台上跑,绕的路真是太多了。

再次make install,还是不行,报错如下

make[1]: *** No rule to make target `usr/local/php-4.4.8/sapi/cli/php', needed by `install-pear-packages'.  Stop.

make: *** [install-pear] Error 2

usr/local/php-4.4.8/sapi/cli/php,奇葩错误,usr前竟然少了个/,没办法,gedit /usr/local/php-4.4.8-arm/php-4.4.8/Makefile改回来,再次maike install,出现

Php cannot execute binary file,把usr/local/php-4.4.8/sapi/cli/php拷贝到php-4.4.8_arm

/php-4.4.8/sapi/cli/里,注意备份php,make install,成功,同理,把备份的arm版php拷贝回来,不然在开发板上也是跑不了的。

这就是apache+php全部的移植过程

剩下的就是如何修改配置文件将apache和php关联起来,百度一搜大把,前辈们还是很给力的,我就不写了。之所以要写这一篇文章,一是记录,二是网上的教程太多太乱,遇到的问题也因人而异,当然,这文章记录的问题也不一定每个人都会遇到,而遇到的问题这篇文章也不一定有,但我想说的是,无论遇到什么问题,不要放弃,耐心分析,善于百度,问题总可以解决的。

移植过程主要参考

http://wenku.baidu.com/link?url=JsY6Daj0RkRAX86IxAA3iHBAtBi2NBqcV6Kp1M1Z9QU0getIQ1tvotWjLWaevkUHBeqKrhC_6IhoQyFBE5PAk2xFePNKD6BWJuhwA-Opa47

以及大量的博客

另外,转载请指明出处:http://www.cnblogs.com/wupengda/p/4720555.html

今后,还会写上加入sqlite的移植经验。

S3C6410移植apache和php的更多相关文章

  1. MIPS平台移植apache 2.2.7

    参考文章: http://wenku.baidu.com/view/94e08a20a5e9856a561260e2.html http://httpd.apache.org/docs/2.4/ins ...

  2. S3C6410移植u-boot

    1.首先下载u-boot(ftp://ftp.denx.de/pub/u-boot) wget ftp://ftp.denx.de/pub/u-boot/u-boot-latest.tar.bz2 2 ...

  3. JDBC连接数据库经验技巧(转)

    Java数据库连接(JDBC)由一组用 Java 编程语言编写的类和接口组成.JDBC 为工具/数据库开发人员提供了一个标准的 API,使他们能够用纯Java API 来编写数据库应用程序.然而各个开 ...

  4. Lucene学习注意要点

    相关书籍: <Lucene实战>第二版: <搜索引擎基础教程>: <Lucene搜索引擎开发进阶实战>:(我现在看得书) 学习注意要点: 不要盲目从代码入手,而要先 ...

  5. S3C6410嵌入式应用平台构建(四)——linux-3.14.4移植到OK6410-(初步启动)

    这次,还是把基本的基于我目前最新的Linux源码进行移植到OK6410吧,同时也写下我移植过程中遇到的问题及解决方法,不过有些方法是借鉴网上的,有些是自己加的,会有一些小bug. 一.基本工作 1. ...

  6. linux 3.4.103 内核移植到 S3C6410 开发板 移植失败 (问题总结,日本再战!)

    linux 3.4.103 内核移植到 S3C6410 开发板 这个星期差点儿就搭在这里面了,一開始感觉非常不值得,移植这样的浪费时间的事情.想立刻搞定,然后安安静静看书 & coding. ...

  7. S3C6410板子移植 Android2.2

    一:Android简介 1.什么是Android: Android是一种基于linux的自由及开放源代码的操作系统,主要适用于移动设备,如智能手机和平板电脑,是由google公司和开放手机联盟领导和开 ...

  8. S3C6410嵌入式应用平台构建(六)——linux-3.14.4移植到OK6410-(Yaffs2文件制作)

    本文主要讲怎用利用yaffs2工具和busybox制作yaffs2文件系统镜像.大多数都是参照网上的,目的在于记录学习,不做任何用途. 一.制作mkyaffs2image工具 进入yaffs2源码目录 ...

  9. S3C6410嵌入式应用平台构建(五)——linux-3.14.4移植到OK6410-(Nand分区问题)

    前一篇文章,我们的Linux能后启动了,只是在识别nand时候,没有获取到时钟源,导致后面的分区没哟进行. 我们从启动的log发现: [06/08-11:25:41:371]s3c24xx-nand ...

随机推荐

  1. jQuery效率提升建议

    jQuery简洁通用的方法集把编码者从繁重的工作中解脱出来,也拉低了进入javascript的门槛,初学者对浏览器兼容性一无所知的情况下,几行代码就可以写出超炫的特效.网上有一篇文章转载比较泛滥,已经 ...

  2. iframe在iphone6 plus的safari下子页面的宽度不受父页面控制的bug

    这是想要的效果: 样式设置是iframe外面的宽度为100%,iframe的宽度为父元素的90%,高度为宽度 除以1.6,固定比例, 正常显示就是上面的样子,但是,问题出现在iphone特定手机特定版 ...

  3. 使用签名来保证ASP.NET MVC OR WEBAPI的接口安全

    当我们开发一款App的时候,App需要跟后台服务进行通信获取或者提交数据.如果我们没有完善的安全机制则很容易被别用心的人伪造请求而篡改数据. 所以我们需要使用某种安全机制来保证请求的合法.现在最常用的 ...

  4. Python_Day_02 str内部方法总结

    刚开始学习Python,看了一天的字符串内部方法,现在来总结一下. capitalize(self) 将一句话的首字母变大写,其他字母都变小 name = "love PyThon" ...

  5. Git 初始化版本库

    创建带工作区的版本库 在开始一个新项目时,首先就要创建并初始化代码库.如果是在本机的工作目录中,那么: $ git init 也就够用了.如果想要初始化的版本库不在当前目录,需要为 git init ...

  6. 自己封装的一个LoadRes组件

    这两周一直太忙,没有好好处理上上上周遇到的一个让我加班到凌晨的问题,这个问题是判断flash的加载. 之前的思路是让flash的人在制作flash的时候,加入了一个回调方法,该方法再会回调我页面的方法 ...

  7. form表单提交数据

    js代码: // form 跳转 gotourl//跳转的页面 options json格式参数 function FromGoTo(gotourl, options) { var inputhtml ...

  8. 背水一战 Windows 10 (31) - 控件(按钮类): ButtonBase, Button, HyperlinkButton, RepeatButton, ToggleButton, AppBarButton, AppBarToggleButton

    [源码下载] 背水一战 Windows 10 (31) - 控件(按钮类): ButtonBase, Button, HyperlinkButton, RepeatButton, ToggleButt ...

  9. dobbo zookeeper 认识

    dubbo 主要使用来整合各种协议的服务,服务提供者可以向dubbo平台注册服务,服务消费都可以看到所有服务的详细信息,而已可以调用所提供的服务接口.zookeeper:主是要服务的集群,配置管理(如 ...

  10. codeforces 632+ E. Thief in a Shop

    E. Thief in a Shop time limit per test 5 seconds memory limit per test 512 megabytes input standard ...