前言
续前面boa移植链接: boa服务器移植,在这基础之上,更改编译方式,使其boa服务器能够在开发板上运行,然后能够在电脑上访问服务器。
BOA服务器在开发板(fs4412)的移植过程
- 查看交叉编译器的类型,并查看选中的工具链,我这里用的是gcc-4.6.4版本
linux@linux:~$ cd /home/linux/fs4412/toolchain/gcc-4.6.4/bin
linux@linux:~/fs4412/toolchain/gcc-4.6.4/bin$ ls
2. 指定交叉编译工具链
linux@linux:~$ cd boa-0.94.13/src/
linux@linux:~/boa-0.94.13/src$ vi Makefile
将Makefile中的指定编译器改为
# CC = gcc
CC = arm-none-linux-gnueabi-gcc
- 删除原来编译的文件,重新编译
linux@linux:~/boa-0.94.13/src$ make clean
linux@linux:~/boa-0.94.13/src$ make
- 将编译生成的文件拷贝到之前的boa文件夹下,查看拷贝文件的属性是支持在ARM平台下运行的文件
linux@linux:~/boa-0.94.13/src$ cp boa /home/linux/boa/
linux@linux:~/boa-0.94.13/src$ cp boa_indexer /home/linux/boa/
linux@linux:~/boa-0.94.13/src$ file boa
boa: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.38, not stripped
linux@linux:~/boa-0.94.13/src$ file boa_indexer
boa_indexer: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.38, not stripped
- 将boa/cgi-bin/目录下test.c重新编译
linux@linux:~/boa/cgi-bin$ arm-none-linux-gnueabi-gcc -o test.cgi test.c
linux@linux:~/boa/cgi-bin$ file test.cgi
test.cgi: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.38, not stripped
linux@linux:~/boa/cgi-bin$
- 将整个/boa目录复制到,nfs共享跟目录下面
linux@linux:~$ sudo cp -rf boa/ /opt/4412/rootfs/
- 测试,在电脑(ubuntu)中浏览器进行访问
出现了这样的一个错误,/home/linux/boa这个目录在开发板上找不到,所以我们需要查看这个boa在开发板的目录,更改某个头文件路径和配置文件。
linux@linux:~/boa-0.94.13/src$ vi defines.h +30
将
#define SERVER_ROOT "/home/linux/boa"
改为:
#define SERVER_ROOT "/boa"
将配置文件boa.conf也修改
然后删除原来编译的文件重新编译,重新拷贝文件过去
linux@linux:~/boa-0.94.13/src$ make clean
linux@linux:~/boa-0.94.13/src$ make
linux@linux:~/boa-0.94.13/src$ sudo cp boa /opt/4412/rootfs/boa/
linux@linux:~/boa-0.94.13/src$ sudo cp boa_indexer /opt/4412/rootfs/boa/
重新执行
在电脑(ubuntu)上访问开发板的网址
在点跳转的时候出现了一个错误
查看log下的日志文件显示以下信息:
[01/Jan/1970:00:00:53 +0000] boa.c:211 - getpwuid: No such file or directory
解决办法:将boa.c中的drop_privs函数以下几行注释掉
#if 0
if (passwdbuf == NULL) {
DIE("getpwuid");
}
if (initgroups(passwdbuf->pw_name, passwdbuf->pw_gid) == -1) {
DIE("initgroups");
}
#endif
然后重新编译拷贝boa文件到nfs共享目录下
太难了,点个赞吧!