TI DaVinci DM6467 基於 lighttpd 搭建嵌入式網頁服務器

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,查看測試網頁內容

發佈了34 篇原創文章 · 獲贊 8 · 訪問量 9萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章