转自: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三个文件夹,如下图所示:
 
2. 配置
2.1. 在安装目录 /opt/web/lighttpd-1.4.30-x86 中手动创建如下文件夹:cache、cgi-bin、config、log、sockets、upload、vhosts、webpages。如下图所示:
 

2.2. 将源码包中doc/config目录下的config.d、lighttpd.conf和modules.conf复制到安装目录中config文件夹里面,如下图所示:

 

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 = 
server.max-connections = 
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文件夹里面,如下图所示:
3.3. 开启命令台,cd进入到lighttpd可执行文件的安装目录:cd /opt/web/lighttpd-1.4.30-x86/sbin/
3.4. 执行命令启动lighttpd服务器:./lighttpd -f ../config/lighttpd.conf ,如下图所示:

3.5. 启动网页浏览器,如 Google Chrome,输入本机IP地址,回车,即可浏览到刚才创建的主页了,如下图所示:

3.6. 关闭服务器:killall lighttpd

 
结束语:
        由于本人移植lighttpd的目的是为了开发嵌入式应用,因此配置文件中的设置都是针对嵌入式系统中有限的资源而作的配置,测试OK后即可把这些配置文件原封不动地复制到开发板直接应用。

最新文章

  1. 向 div 元素添加圆角边框:
  2. Bzoj1208 [HNOI2004]宠物收养所
  3. jQuery multiselect的使用
  4. 项目配置laungchImage
  5. java中 ==与equals 有什么区别?
  6. ACM: 限时训练题解-Heavy Coins-枚举子集-暴力枚举
  7. C#自定义控件背景色透明的方法
  8. PPPoE Server Under Ubuntu/Debian
  9. SDK Hello world(直接使用SDK封装)
  10. Linux历史上线程的3种实现模型
  11. android中对Bitmap图片设置任意角为圆角
  12. UILabel的讲解
  13. Java之File类
  14. Linux 链接详解----静态链接实例分析
  15. 【转】Android Hook框架Xposed详解
  16. [经验交流] kubeadm 安装 kubernetes 一年过期的解决办法
  17. HTTP请求8种方法
  18. inception v1-v3 &amp; Xception
  19. Python学习(二十八)—— Django模板系统
  20. TCL脚本语言基础介绍

热门文章

  1. 2017多校第5场 HDU 6085 Rikka with Candies bitset
  2. HDU 6118 度度熊的交易计划 最大费用可行流
  3. myeclipse安装插件phpeclipse后进行PHP代码编写
  4. Introducing the Filter Types
  5. Java字符串易错方法总结
  6. 错误:在maven install是抛出 “1.5不支持diamond运算符,请使用source 7或更高版本以启用diamond运算符”
  7. Spring MVC源码——Root WebApplicationContext
  8. 洛谷——P1190 接水问题
  9. 【IO】同步、异步、阻塞、非阻塞的理解
  10. noip 2016 day1 T1玩具谜题