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,檢視測試網頁内容