Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2884697
  • 博文数量: 674
  • 博客积分: 17881
  • 博客等级: 上将
  • 技术积分: 4849
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-17 10:15
文章分类

全部博文(674)

文章存档

2013年(34)

2012年(146)

2011年(197)

2010年(297)

分类: LINUX

2010-07-17 10:12:27

1       Mini_httpd-1.19
1.1      下载与编译
mini_httpd-1.19.tar.gz
1.2      安装与配置
mini_httpd程序主要有2个文件:
/bin/mini_httpd
/etc/mini_httpd.conf    (主配置文件)
 
支持GET、HEAD、POST方法
* 支持CGI功能
* 支持基本的验证功能
* 支持安全 .. 上级目录功能
* 支持通用的MIME类型
* 支持目录列表功能
* 支持使用 index.html, index.htm, index.cgi 作为首页
* 支持多个根目录的虚拟主机
* 支持标准日志记录
* 支持自定义错误页
* Trailing-slash redirection
本系统中,web服务器根目录为:/usr/web,首页为index.html。配置文件为/etc/mini_httpd.conf,启动命令为:mini_httpd -C /etc/mini_httpd.conf;其配置内容为:
# GPL $Id: mini_httpd.conf,v 1.1.1.1 2005/02/28 18:22:49 cvonk Exp $
# configuration for HTTP(s) server (mini_httpd)
#
nochroot
#dir=/web/
data_dir=/usr/web/
#data_dir=/var/httpd
user=root
#logfile=/var/httpd/mini_httpd.log
#ssl
# instead of the .pem below, it should probably use the same cert as
# VPN or WPA
#certfile=/etc/sysconfig/mini_httpd/mini_httpd.pem
cgipat=**.cgi
1.3      使用与维护
启动:
# mini_httpd -C /etc/mini_httpd.conf
停止:
# kill PID
 
2       boa-0.94.13
2.1      下载与编译
下载:boa-0.94.13.tar.gz
直接在boa/src目录下执行make即可生成boa可执行文件。
 
2.2      安装与配置
boa程序主要有3个文件:
/bin/boa
/etc/boa/boa.conf    (主配置文件)
/etc/mime.conf        (注意将权限改为777)
 
LINUX下的应用程序的配置都是以配置文件的形式提供的,一般的都是放在目标板/etc/目录下或者/etc/config目录下,但boa的配置文件boa.conf一般都放置在目标板 /etc/boa/boa.conf 目录下。
例如一个典型的boa.conf文件格式如下:
 
ServerName AT91SAM9261
DocumentRoot /home/web
ScriptAlias /cgi-bin/ /home/web/cgi-bin/
ScriptAlias /index.html /home/httpd/html/index.html
它指定了HTML页面(例如index.html必须放到/home/web/目录下,cgi可执行文件必须放到/home/web/cgi-bin目录下)
 
建议阅读文章:
 
boa 支持CGI,不过不一定用C,只要符合CGI要求,用 perl/php/py或shell脚本都是可以的。比如有人就在uC下使用了boa+php(cgi):
2.3      使用与维护
启动命令与运行打印信息:
/ # boa
[27/May/2009:23:40:21 +0000] boa: server version Boa/0.94.13
[27/May/2009:23:40:21 +0000] boa: server built Feb 28 2004 at 21:47:23.
[27/May/2009:23:40:21 +0000] boa: starting server pid=902, port 80
/ # [27/May/2009:23:40:40 +0000] request from 10.13.88.186 "GET /favicon.ico HTy
[27/May/2009:23:40:50 +0000] request from 10.13.88.186 "GET /favicon.ico HTTP/1y
 
 
3       lighttpd-1.4.18
3.1      下载与编译
下载:lighttpd-1.4.18.tar.gz
 
X86&FC6版本:
# ./configure -prefix=/usr/local/lighttpd-1.4.22
 
lighttpd-1.4.22版本,对于AT91SAM9261 & arm-linux-2.6.20& arm-linux-gcc 3.4.4,执行 ./configure 时会报错:
configure: error: zlib-headers and/or libs where not found, install them or build with --without-zlib
所以退而采用lighttpd-1.4.18版本:
# tar –xzvf lighttpd-1.4.18.tar.gz
# cd lighttpd-1.4.18
# export CC=arm-linux-gcc
# export AR=arm-linux-ar
# export LD=arm-linux-ld
# export RANLIB=arm-linux-ranlib
# export STRIP=arm-linux-strip
# ./configure -prefix=/usr/lighttpd-1.4.18 -host=arm-linux --disable-FEUTARE -disable-ipv6 -disable-lfs
# make
# make install
这里特别注意一下:-prefix=/usr/lighttpd-1.4.18 ,是将软件先装在Host的/usr/lighttpd-1.4.18目录内,然后将其复制到开发板的/usr/lighttpd-1.4.18目录下。我之所以这样做是因为这个软件在 make install时会配置他私有的库文件的路径,在开发板运行时会在-prefix= 的文件加下找他的私有库文件。而我又是交叉编译给开发板,这样配置比较方便移植。
--disable-FEUTARE -disable-ipv6 -disable-lfs 可不加。
3.2      安装与配置
3.2.1    安装到ARM文件系统
将Host上安装好的/usr/lighttpd-1.4.18目录,复制到开发板的/usr/目录下:
# cp –a /usr/lighttpd-1.4.18 /usr/
3.2.2    配置lighttpd.conf文件
将编译目录下doc/lighttpd.conf文件拷到AT91SAM9261 & arm-linux-2.6.20的文件系统/etc目录下,并作如下修改:
(1)、设置web服务的根目录server.document-root
server.document-root        = "/srv/www/htdocs/"
改为
server.document-root        = "/home/web/"
 
(2)、server.modules中使能"mod_cgi"和"mod_fastcgi"
server.modules              = (
                                "mod_fastcgi",
                                "mod_cgi")
(3)、屏蔽URL相关语句
屏蔽以下语句,否则嵌入式这样的小系统下可能无法启动
# $HTTP["url"] =~ "\.pdf$" {
#   server.range-requests = "disable"
# }
(4)、使能“.py”、“.sh” 、“.cgi”类型CGI
修改 :
cgi.assign = (".cgi" => ""
            )
对于带扩展名且需要特定解析程序执行的CGI,可以指定解析程序的路径,如:
cgi.assign = ( ".pl" => "/usr/bin/perl",
".cgi" => "/usr/bin/perl" )
对于带扩展名切不需要特定解析程序就能执行的CGI,可指定解析程序为空,如:
cgi.assign = (".cgi" => "")
对于不带扩展名的CGI程序,只能通过固定路径存取了,如:
cgi.assgin = ( "/cgi-bin/mycgi" => "/usr/local/cgi/mycgi )
具体配置如下:
static-file.exclude-extensions = ( ".php", ".sh", ".pl", ".fcgi", ".py" )
#### CGI module
CGI.assign                 = ( ".sh"  => "/bin/sh",
                               ".py"  => "/usr/python2.5.4/bin/python",
                               ".pl"  => "/usr/bin/perl",
                               ".cgi" => "" )
 (5)、禁止log功能
ARM文件系统可能不能读写,所以log相关设置用#号注释掉:
## where to send error-messages to
# server.errorlog             = "/var/log/lighttpd/error.log"
 
#### accesslog module
# accesslog.filename          = "/var/log/lighttpd/access.log"
 
(6)、开看程序需要那些动态库(可选)
[root@TianLinux lighttpd-1.4.22]# arm-linux-readelf -d /usr/ztian/work/lighttpd/lighttpd-1.4.18/src/lighttpd
 
Dynamic section at offset 0x200d0 contains 21 entries:
  标记        类型                         名称/值
 0x00000001 (NEEDED)                     共享库:[libdl.so.2]
 0x00000001 (NEEDED)                     共享库:[libc.so.6]
 0x0000000c (INIT)                       0xc1b8
 0x0000000d (FINI)                       0x22e8c
 0x00000004 (HASH)                       0x8128
 0x00000005 (STRTAB)                     0xa310
 0x00000006 (SYMTAB)                     0x8b40
 0x0000000a (STRSZ)                      5925 (bytes)
 0x0000000b (SYMENT)                     16 (bytes)
 0x00000015 (DEBUG)                      0x0
 0x00000003 (PLTGOT)                     0x301a0
 0x00000002 (PLTRELSZ)                   960 (bytes)
 0x00000014 (PLTREL)                     REL
 0x00000017 (JMPREL)                     0xbdf8
 0x00000011 (REL)                        0xbdc0
 0x00000012 (RELSZ)                      56 (bytes)
 0x00000013 (RELENT)                     8 (bytes)
 0x6ffffffe (VERNEED)                    0xbd30
 0x6fffffff (VERNEEDNUM)                 2
 0x6ffffff0 (VERSYM)                     0xba36
 0x00000000 (NULL)                       0x0
You have new mail in /var/spool/mail/root
 
3.3      使用与维护
启动命令与运行打印信息:
# /usr/lighttpd-1.4.18/sbin/lighttpd -f /etc/lighttpd.conf
2009-06-02 23:50:12: (log.c.75) server started
停止命令与停止打印信息:
# kill “PID”
2009-06-03 00:42:19: (server.c.1470) server stopped by UID = 0 PID = 837
 
添加到PC启动服务:
cp ./doc/rc.lighttpd.redhat /etc/rc.d/init.d/lighttpd
chown root:root /etc/rc.d/init.d/lighttpd
chmod 755 /etc/rc.d/init.d/lighttpd
chkconfig --add lighttpd
4       它们对python CGI的支持
Mini_http、boa、lighttpd都支持python写的CGI,如果python环境没有设置好,会出现不支持import的现象。其中lighttpd支持最为完善灵活。
 
 
参考文献
[1]          CGI,BOA实现下载功能,求教
[2]          移植多款轻量级 Web服务器到ARM-Linux系统 http://blog.chinaunix.net/u1/34474/showart_488114.html
[3]          arm 移植 lighttpd + CGI 测试 http://blog.chinaunix.net/u1/39383/showart_1855731.html
[4]          lighttpd,thttpd,shttpd - 轻量级webserver介绍
 
阅读(1956) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~