輕量級web服務器lighttpd的編譯及配置(for x86-linux)


轉自:http://blog.163.com/ljf_gzhu/blog/static/131553440201211522317367/

 

備注:

PC Linux:Ubuntu-10.10
Linux用戶:root
lighttpd版本:1.4.30
gcc版本:4.4.5 
 
1. 編譯、安裝
1.1. 先到lighttpd官網下載對應版本的軟件包:
我下載的是 lighttpd-1.4.30.tar.gz
1.2. 將壓縮包解壓到任意目錄(我的是 /root/Desktop/common)得到文件夾 lighttpd-1.4.30
1.3. 在文件夾 lighttpd-1.4.30 中創建shell腳本,命名為:configure-x86.sh
1.4. 在shell腳本 configure-x86.sh 中輸入如下代碼:
#! /bin/sh
./configure --prefix=/opt/web/lighttpd-1.4.30-x86 --host=i686-pc-linux --build=i686-pc-linux --disable-FEATURE --enable-shared --disable-static --disable-lfs --disable-ipv6 --without-PACKAGE --without-valgrind --without-openssl --without-kerberos5 --without-pcre --without-zlib --without-bzip2 --without-lua
1.5. 打開控制台,cd進入 lighttpd-1.4.30 目錄
1.6. 給 configure-x86.sh 文件添加可執行屬性,執行命令:
chmod +x configure-x86.sh
1.7. 配置lighttpd,執行命令:
./configure-x86.sh
1.8. 編譯lighttpd,執行命令:
make
1.9. 安裝lighttpd,執行命令:
make install
1.10. 安裝完成后,在安裝目錄 /opt/web/lighttpd-1.4.30-x86 中生成 lib、sbin和share三個文件夾,如下圖所示:
輕量級web服務器lighttpd的編譯及配置(for x86-linux) - Jim - Jim Liang
 
 
2. 配置
2.1. 在安裝目錄 /opt/web/lighttpd-1.4.30-x86 中手動創建如下文件夾:cache、cgi-bin、config、log、sockets、upload、vhosts、webpages。如下圖所示:
輕量級web服務器lighttpd的編譯及配置(for x86-linux) - Jim - Jim Liang
 
 2.2. 將源碼包中doc/config目錄下的config.d、lighttpd.conf和modules.conf復制到安裝目錄中config文件夾里面,如下圖所示:
輕量級web服務器lighttpd的編譯及配置(for x86-linux) - Jim - Jim Liang
 
 2.3. 修改剛復制過來的lighttpd.conf文件
1)將16行至20行修改為如下褐色加粗字體所示:
var.log_root    =  "/opt/web/lighttpd-1.4.30-x86/log"
var.server_root =  "/opt/web/lighttpd-1.4.30-x86"
var.state_dir   =  "/opt/web/lighttpd-1.4.30-x86"
var.home_dir    =  "/opt/web/lighttpd-1.4.30-x86"
var.conf_dir    =  "/opt/web/lighttpd-1.4.30-x86/config"
 2)將61行和93行修改為如下褐色加粗字體所示:
var.cache_dir   =  server_root + "/cache"
server.use-ipv6 =  "disable"
3)將104和105行注釋掉,如下所示:
#server.username  = "lighttpd"
#server.groupname = "lighttpd"
4)將115行修改為如下褐色加粗字體所示:
server.document-root =  server_root + "/webpages"
5)將127行注釋掉,如下所示:
#server.pid-file = state_dir + "/lighttpd.pid"
6)如果不需要查看錯誤日志文件,可以將141行注釋掉,如下所示:
#server.errorlog             = log_root + "/error.log"
7)將152行、158行、191行注釋掉,如下所示:
#include "conf.d/access_log.conf"
#include "conf.d/debug.conf"
#server.network-backend = "linux-sendfile"
8)根據系統資源設置207行和225行的數值,本系統的設置分別如下褐色加粗字體所示:
server.max-fds =  256
server.max-connections =  128
9)將314至316行注釋掉,如下所示:
#$HTTP["url"] =~ "\.pdf$" {
#  server.range-requests = "disable"
#}
10)將373行修改為如下褐色加粗字體所示:
server.upload-dirs =  ( "/opt/web/lighttpd-1.4.30-x86/upload" )
 
2.4. 修改剛復制過來的modules.conf文件
1)找到43行,將光標定位到逗號后面,回車,插入如下內容:
"mod_alias",
2)使能CGI模塊,將138行的注釋符去掉,如下所示:
include "conf.d/cgi.conf"
 
2.5. 修改剛復制過來的conf.d文件夾里面的cgi.conf文件
1)將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" )
2)將28行的注釋符去掉,如下所示:
alias.url += ( "/cgi-bin" => server_root + "/cgi-bin" )
 
3. 運行測試
3.1. 在任意地方創建一空白文檔,在文檔中輸入如下HTML代碼:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>lighttpd測試</title>
</head>
<body>
<p>輕量級web服務器lighttpd的編譯及配置(for x86-linux)</p>
<hr>
<p>測試頁面</p>
</body>
</html>
3.2. 將文檔保存為index.html,並復制到安裝目錄中的webpages文件夾里面,如下圖所示:
輕量級web服務器lighttpd的編譯及配置(for x86-linux) - Jim - Jim Liang
3.3. 開啟命令台,cd進入到lighttpd可執行文件的安裝目錄: cd /opt/web/lighttpd-1.4.30-x86/sbin/
3.4. 執行命令啟動lighttpd服務器: ./lighttpd -f ../config/lighttpd.conf ,如下圖所示:
輕量級web服務器lighttpd的編譯及配置(for x86-linux) - Jim - Jim Liang
 3.5. 啟動網頁瀏覽器,如 Google Chrome,輸入本機IP地址,回車,即可瀏覽到剛才創建的主頁了,如下圖所示:
輕量級web服務器lighttpd的編譯及配置(for x86-linux) - Jim - Jim Liang
 3.6. 關閉服務器: killall lighttpd
 
結束語:
        由於本人移植lighttpd的目的是為了開發嵌入式應用,因此配置文件中的設置都是針對嵌入式系統中有限的資源而作的配置,測試OK后即可把這些配置文件原封不動地復制到開發板直接應用。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM