移植shttpd Web服务器到ARM Linux系统

一、下载并解压
下载的官方主页:
我下载的是shttpd-1.39.tar.gz
解压:
[tekkamanninja@Tekkaman-Ninja source]$ tar zxvf shttpd-1.39.tar.gz

 

二、配置和交叉编译
[tekkamanninja@Tekkaman-Ninja source]$ cd shttpd-1.39 
[tekkamanninja@Tekkaman-Ninja shttpd-1.39]$ cd src/
[tekkamanninja@Tekkaman-Ninja src]$ kwrite Makefile

 

只需在前面加上交叉编译器路径就好:
CC = /home/tekkamanninja/working/gcc4.1.1/gcc-4.1.1-glibc-2.3.2/arm-9tdmi-linux-gnu/bin/arm-9tdmi-linux-gnu-gcc
AR = /home/tekkamanninja/working/gcc4.1.1/gcc-4.1.1-glibc-2.3.2/arm-9tdmi-linux-gnu/bin/arm-9tdmi-linux-gnu-ar
CFLAGS =  -DNO_SSL

 

加上CFLAGS =  -DNO_SSL,是因为如果编译SSL支持,会因符号未定义而无法通过。所以我去除了SSL 支持。

 

交叉编译:

[tekkamanninja@Tekkaman-Ninja src]$ make unix

开看程序需要那些动态库:
[tekkamanninja@Tekkaman-Ninja src]$ ~/working/gcc4.1.1/gcc-4.1.1-glibc-2.3.2/arm-9tdmi-linux-gnu/bin/arm-9tdmi-linux-gnu-readelf -d shttpd

Dynamic section at offset 0x12cc8 contains 20 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x0000000c (INIT)                       0x9180
 0x0000000d (FINI)                       0x18708
 0x00000004 (HASH)                       0x8128
 0x00000005 (STRTAB)                     0x8a5c
 0x00000006 (SYMTAB)                     0x843c
 0x0000000a (STRSZ)                      807 (bytes)
 0x0000000b (SYMENT)                     16 (bytes)
 0x00000015 (DEBUG)                      0x0
 0x00000003 (PLTGOT)                     0x22d90
 0x00000002 (PLTRELSZ)                   704 (bytes)
 0x00000014 (PLTREL)                     REL
 0x00000017 (JMPREL)                     0x8ec0
 0x00000011 (REL)                        0x8e88
 0x00000012 (RELSZ)                      56 (bytes)
 0x00000013 (RELENT)                     8 (bytes)
 0x6ffffffe (VERNEED)                    0x8e48
 0x6fffffff (VERNEEDNUM)                 1
 0x6ffffff0 (VERSYM)                     0x8d84
 0x00000000 (NULL)                       0x0


将编译好的程序放入开发板的文件系统下:
[tekkamanninja@Tekkaman-Ninja src]$ cp shttpd /home/tekkamanninja/working/nfs/rootfs/sbin/

 

三、运行shttpd

因为shttpd 没有配置文件,所以配置是由启动参数加的,比如我在开发板中操作如下:
[root@~]#shttpd -root /var/www -ports 80  &

意思是Web 根目录为/var/www 用80端口提供服务。

 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwzywg.html