参考文章:http://zh200581134.blog.163.com/blog/static/96010202012328111616767/
1、编译和安装:
1)、从http://www.lighttpd.net/download/ 下载 lighttpd-1.4.32.tar.gz;
2)、解压:tar -xzvf lighttpd-1.4.32.tar.gz;
3)、在lighttpd-1.4.32下创建configure.sh脚本;在脚本中输入:
./configure --prefix=/home/pub/johnny/network/install --host=mips-linux-gnu --disable-FEATURE --disable-lfs --disable-ipv6 --without-PACKAGE --without-openssl --without-kerberos5 --without-pcre --without-zlib --without-bzip2 --without-lua "CC=mips-linux-gnu-gcc -EL" "CFLAGS=-EL" "LDFLAGS=-EL"
4)、创建/home/pub/johnny/network/install 目录;
5)、配置lighttpd:./configure.sh;
6)、编译lighttpd:make
7)、安装lighttpd:make install
8)、安装成功后在/home/pub/johnny/network/install/生成三个目录:lib/ sbin/ share/
2、配置:
1)、在安装目录 /home/pub/johnny/network/install/ 中手动创建如下文件夹:cache、cgi-bin、config、log、sockets、upload、vhosts、webpages
2)、将源码包中doc/config目录下的config.d、lighttpd.conf和modules.conf复制到安装目录中config文件夹里面;
3)、修改刚复制过来的lighttpd.conf文件:
(1)、将16行至20行修改为如下所示:
var.log_root = "/home/pub/johnny/network/install/log"
var.server_root = "/home/pub/johnny/network/install"
var.state_dir = "/home/pub/johnny/network/install"
var.home_dir = "/home/pub/johnny/network/install"
var.conf_dir = "/home/pub/johnny/network/install/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 = ( "/home/pub/johnny/network/install/upload" )
4)、修改刚复制过来的modules.conf文件
(1)、找到44行,将注释符去掉,如下所示:
"mod_alias",
(2)、使能CGI模块,将138行的注释符去掉,如下所示:
include "conf.d/cgi.conf"
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" )
(6)、在安装目录中的webpages文件夹里面创建index.html文件
<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>
3、移植:
1)、将安装目录 /home/pub/johnny/network/install从主机复制到开发板中相同的/home/pub/johnny/network/install目录。
2)、进入开发板,启动lighttpd服务器:
./lighttpd -f ../config/lighttpd.conf
3)、在PC上打开浏览器,输入:http://192.168.9.159/index.html,成功打开开发板上的网页;
4、测试fastcgi模块:
1)、注释掉modules.conf中的138行:
#include "conf.d/cgi.conf"
去掉132行的注释,使能fastcgi:
include "conf.d/fastcgi.conf"
2)、在conf.d文件夹里面的fastcgi.conf里面添加:
fastcgi.server = (
"/test.php" =>
((
"socket" => "/tmp/lighttpd.player.server.socket",
"bin-path" => "/tmp/bin/test-fastcgi",
"max-procs" => 1,
# "host" => "127.0.0.1",
# "port" => 8081,
"check-local" => "disable",
))
3)、写一个测试程序:
void main(void)
{
printf("This is test for fastcgi!\n");
sleep(5);
return;
}
编译出可执行文件test-fastcgi;
4)、在PC上运行http://192.168.9.*/test.php,在开发板上打印出printf结果;