移植thttpd Web服务器到嵌入式Linux系统

1 下载并解压
下载地址为:http://www.acme.com/software/thttpd/ 我下载的是最新的2.25b
解压:
2 交叉thttpd 编译
[tekkamanninja@tekkaman-ninja source]$ cd thttpd-2.25b
[tekkamanninja@tekkaman-ninja thttpd-2.25b]$ 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 –host=arm-9tdmi-linux-gnu
[tekkamanninja@tekkaman-ninja thttpd-2.25b]$ make
[tekkamanninja@tekkaman-ninja source]$ tar -xvzf thttpd-2.25b.tar.gz
 3 安装与配置
3.1 拷贝thttpd二进制可执行文件到根文件系统/usr/sbin/目录中
[tekkamanninja@tekkaman-ninja thttpd-2.25b]$ cp thttpd /home/tekkamanninja/working/nfs/rootfs/usr/sbin/
3.2 拷贝thttpd配置文件
[tekkamanninja@tekkaman-ninja thttpd-2.25b]$ cp contrib/redhat-rpm/thttpd.conf /home/tekkamanninja/working/nfs/rootfs/etc/
3.3在开发板上为thttpd创建一个独立的用户:httpd,并用此用户创建httpd服务的根目录html
[root@/root]#adduser httpd
changing password for httpd
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 `httpd' changed by user `root'
password changed.
[root@/root]#exit
process '-/bin/login' (pid 787) exited. scheduling it for restart.
starting pid 790, tty '': '/bin/login'
192.168.1.2 login: httpd
password:
processing /etc/profile...
set search library path in /etc/profile
set user path in /etc/profile
set ps1 in /etc/profile
done
[httpd@/home/httpd]$mkdir html
3.4 拷贝测试网页到httpd服务的根目(可选,测试之用):
[tekkamanninja@tekkaman-ninja thttpd-2.25b]$ cp index.html /home/tekkamanninja/working/nfs/rootfs/home/httpd/html/
我是动态编译所以查看一下需要的动态库 虽然这里只列出了需要libcrypt 和 libc 这两个动态库,但是想要运行thttpd还需要libnss_files 动态库,具体原因请看:http://www.jollen.org/blog/2006/10/library_dependency_1.html
[tekkamanninja@tekkaman-ninja thttpd-2.25b]$ cp -d /home/tekkamanninja/working/gcc4.1.1/gcc-4.1.1-glibc-2.3.2/arm-9tdmi-linux-gnu/arm-9tdmi-linux-gnu/lib/libnss_files* /home/tekkamanninja/working/nfs/rootfs/lib/
你可以在启动文件里增加thttpd的启动命令:thttpd -c /etc/thttpd.conf
注意只有root有启动权限!
4、增加对cgi的支持
默认配置下,thttpd不可以运行gci(特别是动态编译的cgi程序)要想使用cgi支持功能,必须更改thttpd.conf的配置:
# this section overrides defaults
dir=/home/httpd/html
#chroot
#屏蔽chroot是为了运行动态编译的cgi
user=httpd# default = nobody
logfile=/var/log/thttpd.log
pidfile=/var/run/thttpd.pid
# this section _documents_ defaults in effect
port=81
#port参数用于更改端口号(可不改,若还运行了别的web服务器,则需用不同端口)
# nosymlink# default = !chroot
#symlinks
# novhost
cgipat=/cgi-bin/*
#声明cgi程序的目录,是以dir为根目录的路径
# nothrottles
# host=0.0.0.0
# charset=iso-8859-1
移植完成,可以测试了(只需在web浏览器中键入开发板的ip地址即可)。
[tekkamanninja@tekkaman-ninja thttpd-2.25b]$ /home/tekkamanninja/working/gcc4.1.1/gcc-4.1.1-glibc-2.3.2/arm-9tdmi-linux-gnu/bin/arm-9tdmi-linux-gnu-readelf -d thttpd
dynamic section at offset 0x12014 contains 21 entries:
  tag type name/value
 0x00000001 (needed) shared library: [libcrypt.so.1]
 0x00000001 (needed) shared library: [libc.so.6]
 0x0000000c (init) 0x9548
 0x0000000d (fini) 0x16564
 0x00000004 (hash) 0x8128
 0x00000005 (strtab) 0x8c14
 0x00000006 (symtab) 0x8494
 0x0000000a (strsz) 1066 (bytes)
 0x0000000b (syment) 16 (bytes)
 0x00000015 (debug) 0x0
 0x00000003 (pltgot) 0x220e4
 0x00000002 (pltrelsz) 872 (bytes)
 0x00000014 (pltrel) rel
 0x00000017 (jmprel) 0x91e0
 0x00000011 (rel) 0x91a0
 0x00000012 (relsz) 64 (bytes)
 0x00000013 (relent) 8 (bytes)
 0x6ffffffe (verneed) 0x9130
 0x6fffffff (verneednum) 2
 0x6ffffff0 (versym) 0x903e
 0x00000000 (null) 0x0

基于谐波补偿的逆变器波形控制技术研究
汽车安全与保养知识:手动挡比自动挡好在哪里?
三星SK海力士加码半导体设备投资与产量,以缓解行业压力
无人机的优势以及大数据环境下的无人机技术改革分析
2100万像素相机案例分享:PCB的Pin正位度
移植thttpd Web服务器到嵌入式Linux系统
芯片短缺将导致手机电脑汽车主机等涨价
转型物联网行业的日海智能公布了二次修订后的定增方案
虚拟现实如何开始在商业中掀起波澜
NVIDIA CEO 黄仁勋做客 “Acquired Podcast” ,回忆创业心路历程
无风扇工控机优点
物联网技术、标准“水到渠成” 产值链上群雄并起
双色发光二极管外形与符号_双色发光二极管工作原理
医疗机器人或成为未来重要医疗资源
数据中心的近封装光学和共封装光学的应用
声光控灯电路原理分析
压电陶瓷片工作原理 压电陶瓷片如何测量?
matlab最优化实验
mmap原理详解
红外热电堆的特性及应用简析