嵌入式web服务器lighttpd的交叉编译及配置--xilinx zynq

来源:互联网 发布:下载淘宝网到手机桌面 编辑:程序博客网 时间:2024/05/18 19:45

一、前言

最近项目用到嵌入式web服务器lighttpd,在网上找了相关材料并不是很齐全,在这里整理总结一下;

二、编译环境

centos 7.0

lighttpd-1.4.39

pcre-8.38

php-7.0.4

libxml2-2.7.2

交叉编译链 arm-xilinx-linux-gnueabi-

三、编译过程

1、在移植前要先移植pcre否则服务无法启动

1.1、下载解压

<pre name="code" class="plain">wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.00.tar.bz2tar xvf pcre-8.00.tar.bz2 -C ./pcrecd pcre/

1.2配置

./configure --host=<span style="font-family: FangSong_GB2312;">arm-xilinx-linux-gnueabi</span> --prefix=/ --enable-utf8 --enable-unicode-properties

1.3、安装(本人安装在/home/cq/web/lighttpd)

make && make DESTDIR=/home/cq/web/lighttpd install

2、lighttpd编译、安装

2.1先从官网下载软件包
http://www.lighttpd.net/ 这边使用的是lighttp-1.4.39.tar.gz

2.2解压到本地目录我的是/home/cq/web/,

2.3进入解压目录 创建shell脚本,命名为:configure-arm.sh

2.4在configure-arm.sh 加入代码:

#! /bin/shCC=<span style="font-family: FangSong_GB2312;">arm-xilinx-linux-gnueabi</span>-gcc AR=<span style="font-family: FangSong_GB2312;">arm-xilinx-linux-gnueabi</span>-ar LD=<span style="font-family: FangSong_GB2312;">arm-xilinx-linux-gnueabi</span>-ld RANLIB=<span style="font-family: FangSong_GB2312;">arm-xilinx-linux-gnueabi</span>-ranlib STRIP=<span style="font-family: FangSong_GB2312;">arm-xilinx-linux-gnueabi</span>-strip ./configure --prefix=<span style="color: rgb(34, 34, 34); font-size: 15px;">/home/cq/web/lighttpd</span> --host=<span style="font-family: FangSong_GB2312;">arm-xilinx-linux-gnueabi</span> --build=i686-pc-linux --disable-FEATURE --enable-shared --disable-static --disable-lfs --disable-ipv6 --without-PACKAGE --without-valgrind --without-openssl --without-kerberos5 --with-pcre --without-zlib --without-bzip2 --without-lua
2.5打开终端,执行命令

chmod +x configure-arm.sh
2.6配置lighttpd命令:

./configure-arm.sh
2.7编译 安装 lighttpd 命令

make && make install
2.8安装后会在/home/cq/web/lighttpd 下产生3个目录 lib、sbin和share。自己手动在创建如下文件夹:cache、cgi-bin、config、log、sockets、upload、vhosts、webpages。如下图

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


2.9 修改刚复制过来的lighttpd.conf文件
1)将16行至20行修改为如下所示:
var.log_root    = "/home/cq/web/lighttpd/log"
var.server_root = "/home/cq/web/lighttpd"
var.state_dir   = "/home/cq/web/lighttpd"
var.home_dir    = "/home/cq/web/lighttpd"
var.conf_dir    = "/home/cq/web/lighttpd/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/cq/web/lighttpd/upload" )

2.10 修改刚复制过来的modules.conf文件
1)找到43行,将光标定位到逗号后面,回车,插入如下内容:
"mod_alias",
2)使能CGI模块,将138行的注释符去掉,如下所示:
include "conf.d/cgi.conf"

2.11 修改刚复制过来的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 arm-linux)</p>
<hr>
<p>测试页面</p>
</body>
</html>
3.2. 将文档保存为index.html,并复制到安装目录中的webpages文件夹里面
轻量级web服务器lighttpd的交叉编译及配置(for arm-linux) - Jim - Jim Liang
3.3. 将安装目录/home/cq/web/lighttpd/从主机复制到开发板中相同的目录。
3.4. 打开开发板的控制台(串口控制台或者SSH控制台),cd进入到lighttpd可执行文件的安装目录:cd/home/cq/web/lighttpd/sbin/
3.5. 启动lighttpd服务器 ./lighttpd -f ../config/lighttpd.conf
嵌入式web服务器lighttpd的交叉编译及配置(for arm-linux) - Jim - Jim Liang
3.6. 启动网页浏览器,如 Google Chrome,输入开发板的IP地址,回车,即可浏览到刚才创建的主页了
   正常显示则配置成功!
嵌入式web服务器lighttpd的交叉编译及配置(for arm-linux) - Jim - Jim Liang




lighpptd 对php的支持将在下篇文章中进行介绍《web服务器lighttpd 对php的支持》

0 0
原创粉丝点击