Target Board :
LVS301 (TI davinci dm6467)
Host OS :
ubuntu 10.04.4 64-bit
Corss Compiler :
arm-2011.03-41-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
webserver : lighttpd
步骤如下:
1,下载并解压 lighttpd
#tar xzf lighttpd-1.4.30.tar.bz2
2,设置交叉编译工具路径
#export PATH=$PATH:/opt/arm-2011.03/bin
3,配置 lighttpd
#cd lighttpd-1.4.30
#./configure –prefix=/opt/web/lighttpd –host=arm-none-linux-gnueabi --disable-FEUTARE –disable-ipv6 –disable-lfs --without-pcre --without-zlib --without-bzip2
配置选项具体含义可以通过下面命令查看 ./configure --help
--prefix 安装路径选项必须设定为与目标板挂在目录相同,否则会出现 lighttpd 服务器找不到相关动态链接库和配置文件的错误
我计划把编译后的网页服务器目录挂载到目标板的 /opt/web/lighttpd 目录下,所以设置为 /opt/web/lighttpd
--host 交叉编译工具前缀 arm-none-linux-gnueabi
由于开发板环境限制,因此我决定对配置编译文件进行粗略的裁剪。所以用
--disable-FEUTARE 关闭对未来扩展的支持
--disable-ipv6 关闭对 ipv6 的支持
--disable-lfs 关闭对大文件系统的支持(large file system)
--without-pcre
--without-zlib
--without-bzip2
3,编译
#make
4,安装
#make install
编译成功后的可执行文件会复制到安装路径 /opt/web/lighttpd
到此为止,lighttpd的编译完成。下面进行配置 lighttpd
1,在安装目录 /opt/web/lighttpd 中手动创建如下文件夹:cache、cgi-bin、log、sockets、upload、vhosts、webpages
#mkdir cache cgi-bin log sockets upload vhosts webpages
2,将源码包中doc/config目录下的config.d、lighttpd.conf和modules.conf复制到安装目录中config文件夹里面
#cp lighttpd-1.4.30/doc/config /opt/web/lighttpd
3,修改 lighttpd.conf 文件
将16行至20行修改为如下所示:
var.log_root = "/opt/web/lighttpd-1.4.30/log"
var.server_root = "/opt/web/lighttpd-1.4.30"
var.state_dir = "/opt/web/lighttpd-1.4.30"
var.home_dir = "/opt/web/lighttpd-1.4.30"
var.conf_dir = "/opt/web/lighttpd-1.4.30/config"
将61行和93行修改为如下所示:
var.cache_dir = server_root + "/cache"
server.use-ipv6 = "disable"
将104和105行注释掉,如下所示:
#server.username = "lighttpd"
#server.groupname = "lighttpd"
将115行修改为如下所示:
server.document-root = server_root + "/webpages"
将127行注释掉,如下所示:
#server.pid-file = state_dir + "/lighttpd.pid"
如果不需要查看错误日志文件,可以将141行注释掉,如下所示:
#server.errorlog = log_root + "/error.log"
将152行、158行、191行注释掉,如下所示:
#include "conf.d/access_log.conf"
#include "conf.d/debug.conf"
#server.network-backend = "linux-sendfile"
根据系统资源设置207行和225行的数值,本系统的设置分别如下褐色加粗字体所示:
server.max-fds = 256
server.max-connections = 128
将314至316行注释掉,如下所示:
#$HTTP["url"] =~ "\.pdf$" {
# server.range-requests = "disable"
#}
将373行修改为如下所示:
server.upload-dirs = ( "/opt/web/lighttpd-1.4.30/upload" )
4,修改 modules.conf 文件
第43行,将光标定位到逗号后面,回车,插入如下内容:
"mod_alias",
使能CGI模块,将138行的注释符去掉,如下所示:
include "conf.d/cgi.conf"
5,修改 conf.d/cgi.conf 文件
将15至19行这一段配置修改如下:
原文内容:
cgi.assign = ( ".pl" => "/usr/bin/perl",
".cgi" => "/usr/bin/perl",
".rb" => "/usr/bin/ruby",
".erb" => "/usr/bin/eruby",
".py" => "/usr/bin/python" )
更改后:
cgi.assign = (".cgi" => "")
#cgi.assign = ( ".pl" => "/usr/bin/perl",
# ".cgi" => "/usr/bin/perl",
# ".rb" => "/usr/bin/ruby",
# ".erb" => "/usr/bin/eruby",
# ".py" => "/usr/bin/python" )
将28行的注释符去掉,如下所示:
alias.url += ( "/cgi-bin" => server_root + "/cgi-bin" )
6,在目录 /opt/web/lighttpd/webpages/ 下建立测试网页
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>lighttpd测试</title>
</head>
<body>
<p>轻量级web服务器lighttpd的编译及配置(for arm-linux)</p>
<hr>
<p>测试页面</p>
</body>
</html>
7,将安装目录 /opt/web/lighttpd 从主机复制到开发板中相同的 NFS 目录
8,在开发板上启动 lighttpd
#/opt/web/lighttpd/sbin/lighttpd -f /opt/web/lighttpd/config/lighttpd.conf
9,在 HOST PC 上用网页浏览器打开开发板的 IP,查看测试网页内容