部署Lighttpd到252板子

1.先到lighttpd官网下载对应版本的软件包:

如: lighttpd-1.4.30.tar.gz

 

2. 将压缩包解压到任意目录得到文件夹 lighttpd-1.4.30

 

3. 执行配置命令: 

bash ./configure CC=arm-hisiv600-linux-gcc AR=arm-hisiv600-linux-ar LD=arm-hisiv600-linux-ld RANLIB=arm-hisiv600-linux-ranlib STRIP=arm-hisiv600-linux-strip --prefix=/opt/web/lighttpd-1.4.30-arm --host=arm-hisiv600-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

(其中的交叉编译工具、安装目录根据项目要求更改)

 

4.  编译lighttpd,执行命令:
make


5.  安装lighttpd,执行命令: 
make  install(可能出现权限不够,加上sudo解决)

 

6. 安装完成后,在安装目录 /opt/web/lighttpd-1.4.30-x86 中会自动生成 libsbinshare三个文件夹:

 

 

7. 在安装目录 /opt/web/lighttpd-1.4.30-arm 中手动创建如下8个文件夹:cachecgi-binconfiglogsocketsuploadvhostswebpages

 

 

8. 将源码包中doc/config目录下的config.dlighttpd.confmodules.conf复制到安装目录中config文件夹里面,如下图所示:

 

 

9. 修改刚复制过来的lighttpd.conf文件:


1)将16行至20行修改为如下修改:
 var.log_root    = "/opt/web/lighttpd-1.4.30-arm/log"
 var.server_root = "/opt/web/lighttpd-1.4.30-arm"
 var.state_dir   = "/opt/web/lighttpd-1.4.30-arm"
 var.home_dir    = "/opt/web/lighttpd-1.4.30-arm"
 var.conf_dir    = "/opt/web/lighttpd-1.4.30-arm/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-arm/upload" )

(和你的安装路径有关)

 

10. 修改刚复制过来的modules.conf文件:


1)找到43行,将光标定位到逗号后面,回车,插入如下内容:
"mod_alias",


2)使能CGI模块,将138行的注释符去掉,如下修改:
include "conf.d/cgi.conf"

 

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" )

 

12. 在安装目录中的webpages文件夹里面创建一index.html文档,内容自定义:

 

13.将安装目录 /opt/web/lighttpd-1.4.30-arm 从主机复制到252开发板中相同的目录:

 

1)压缩文件lighttpd-1.4.30-arm

tar -czvf 压缩后文件名.tar.gz 要压缩的文件名

 

2) 下载压缩后的文件

sz 压缩后文件名.tar.gz

 

3).ftp上传到开发板(需要传输工具,打开后选择要传的文件所在路径),输入命令:

ftpget  –u 服务器用户名  -p服务器密码  本机ftp服务器IP  文件名

 

4)打开开发板的控制台(串口控制台或者SSH控制台),cd进入到lighttpd可执行文件的安装目录:

cd /opt/web/lighttpd-1.4.30-arm/sbin/

 

5)启动lighttpd服务器 

./lighttpd -f ../config/lighttpd.conf

可能找不到lib,无法启动,在命令后加上-m ../lib(./lighttpd -f ../config/lighttpd.conf -m ../lib

-f后是配置lighttpd.conf的位置,-m是lib所在的位置)

(个人项目更换了目录:/var/www/sbin/lighttpd -f /var/www/config/lighttpd.conf -m /var/www/lib/)

 

6)启动浏览器,输入开发板的IP地址,回车,即可浏览到刚才创建的index.html

 

7)关闭服务器:

killall lighttpd

 

附录:

1.修改端口(不一定需要改)

cd /opt/web/lighttpd-1.4.30-arm/config # vi lighttpd.conf

修改里面的port

posted @ 2019-08-31 01:19  早安帆  阅读(263)  评论(0编辑  收藏  举报