移植lighttpd Web服务器到嵌入式linux系统

一、下载并解压
下载的官方主页:www.lighttpd.net
我下的是目前最新的lighttpd-1.4.18
解压:
[tekkamanninja@tekkaman-ninja source]$ tar xjvf lighttpd-1.4.18.tar.bz2
二、配置和交叉编译
[tekkamanninja@tekkaman-ninja source]$ cd lighttpd-1.4.18
[tekkamanninja@tekkaman-ninja lighttpd-1.4.18]$ 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 ./configure -prefix=/lighttpd  -host=arm-9tdmi-linux-gnu --disable-feutare -disable-ipv6 -disable-lfs  
这里特别注意一下:-prefix=/lighttpd ,我是将软件先装在host的根目录下的lighttpd文件夹内,然后将其复制到开发板的根文件系统的根目录下。我之所以这样做是因为这个软件在make install时会配置他私有的库文件的路径,在开发板运行时会在-prefix= 的文件加下找他的私有库文件。而我又是交叉编译给开发板,这样配置比较方便移植。
--disable-feutare -disable-ipv6 -disable-lfs 可以不加。
[tekkamanninja@tekkaman-ninja lighttpd-1.4.18]$ make
三、程序安装
[tekkamanninja@tekkaman-ninja lighttpd-1.4.18]$ make install
拷贝配置文件到开发板根文件系统的etc文件夹并进行适当修改:
[tekkamanninja@tekkaman-ninja lighttpd-1.4.18]$ cp doc/lighttpd.conf  /home/tekkamanninja/working/nfs/rootfs/etc/
[tekkamanninja@tekkaman-ninja lighttpd-1.4.18]$ kwrite  /home/tekkamanninja/working/nfs/rootfs/etc/lighttpd.conf 
必需修改的地方有:
    server.document-root        = /srv/www/htdocs/
改为server.document-root        = /home/lighttpd/html/
你可以自己定义,这里就是设置web服务的根目录。
屏蔽一下语句,不然嵌入式这样的小系统下可能无法启动
#$http[url] =~ \.pdf$ {
#  server.range-requests = disable
#}
开看程序需要那些动态库:
[tekkamanninja@tekkaman-ninja lighttpd-1.4.18]$ ~/working/gcc4.1.1/gcc-4.1.1-glibc-2.3.2/arm-9tdmi-linux-gnu/bin/arm-9tdmi-linux-gnu-readelf -d src/lighttpd
dynamic section at offset 0x20790 contains 21 entries:
  tag        type                         name/value
 0x00000001 (needed)                     shared library: [libdl.so.2]
 0x00000001 (needed)                     shared library: [libc.so.6]
 0x0000000c (init)                       0xc200
 0x0000000d (fini)                       0x231c0
 0x00000004 (hash)                       0x8128
 0x00000005 (strtab)                     0xa338
 0x00000006 (symtab)                     0x8b48
 0x0000000a (strsz)                      5946 (bytes)
 0x0000000b (syment)                     16 (bytes)
 0x00000015 (debug)                      0x0
 0x00000003 (pltgot)                     0x30860
 0x00000002 (pltrelsz)                   960 (bytes)
 0x00000014 (pltrel)                     rel
 0x00000017 (jmprel)                     0xbe40
 0x00000011 (rel)                        0xbe00
 0x00000012 (relsz)                      64 (bytes)
 0x00000013 (relent)                     8 (bytes)
 0x6ffffffe (verneed)                    0xbd70
 0x6fffffff (verneednum)                 2
 0x6ffffff0 (versym)                     0xba72
 0x00000000 (null)                       0x0
拷贝动态库:
[tekkamanninja@tekkaman-ninja lighttpd-1.4.18]$ cp ~/working/gcc4.1.1/gcc-4.1.1-glibc-2.3.2/arm-9tdmi-linux-gnu/arm-9tdmi-linux-gnu/lib/libdl-2.3.2.so ~/working/nfs/rootfs/lib/
[tekkamanninja@tekkaman-ninja lighttpd-1.4.18]$ cp ~/working/gcc4.1.1/gcc-4.1.1-glibc-2.3.2/arm-9tdmi-linux-gnu/arm-9tdmi-linux-gnu/lib/libdl.s*  ~/working/nfs/rootfs/lib/
在开发板为此程序新建一个用户及存储网页的根目录以及一个log目录:
开发板操作:
[root@~]#adduser -g user lighttpd
changing password for lighttpd
enter the new password (minimum of 5, maximum of 8 characters)
please use a combination of upper and lower case letters and numbers.
enter new password:
bad password: too short.
warning: weak password (continuing).
re-enter new password:
passwd[786]: password for `lighttpd' changed by user `root'
password changed.
[root@~]#
host 操作:
[tekkamanninja@tekkaman-ninja lighttpd-1.4.18]$ cd ../../nfs/rootfs/home/lighttpd/
[tekkamanninja@tekkaman-ninja lighttpd]$ su
口令:
[root@tekkaman-ninja lighttpd]# mkdir html
[root@tekkaman-ninja lighttpd]# chmod 777 html/
[root@tekkaman-ninja lighttpd]# mkdir  ../../var/log/lighttpd
[root@tekkaman-ninja lighttpd]# chmod 777 ../../var/log/lighttpd
将移植好的程序(整个目录,其中包含了bin、sbin、lib和share目录)拷贝到开发板根文件系统的根目录下:
[root@tekkaman-ninja lighttpd]# mv /lighttpd   /home/tekkamanninja/working/nfs/
[root@tekkaman-ninja lighttpd]# exit
exit
四、运行程序
在开发板上操作:
[root@~]#/lighttpd/sbin/lighttpd -f /etc/lighttpd.conf
将测试静态网页放在server.document-root设置的目录下,并在host的浏览器下输入开发板ip,测试通过。
至于cgi的运行,我还不懂配置,有空再研究!

用于活病原体快速检测的微流控系统研究进展
基于CS5463的高速功率计算
建大仁科风速风向传感器介绍
莱福德GM周洪林:2016年营收增长到3.2亿
ARM智能设备,带给你不一样的感受
移植lighttpd Web服务器到嵌入式linux系统
太阳能路灯的实际功率该怎么计算
Marvell推出Plug Computer 3.0 内置W
采用单片机AT89S51和光电开关实现缝纫机生产线计件系统设计
台积电将包揽ASML这批EUV光刻机中的18台
顺丰航空正式迎来第7架B767-300型全货机飞
人工智能深度学习的成功
LOM 3D打印技术的原理及其使用的材料
压敏电阻放保险丝前面还是后面
红米Note 4X:初音未来代言没跑 4种色彩
波士顿动力生产出SpotMini机器人 不久之后就将可以用在多种工作中
ReRAM与NRAM将成全球存储市场两大黑马
uled和量子点区别
解析前端回传解决方案,助力实现C
多层pcb生产,更有助于高精度布线