一:下载源码
下载lighttpd-1.4.54.tar.gz和pcre-8.43.tar.gz
下载连接:lighttpd1.4.54源码及依赖库prce8.43源码资源-CSDN文库
二:交叉编译prce
cd ~/work/pcre/
mkdir _install
tar zxvf pcre-8.43.tar.gz
cd pcre-8.43/
./configure --prefix=/home/hfzuo/work/pcre/_install --host=aarch64-linux-gnu CC=aarch64-linux-gnu-gcc
注意替换自己的安装目录及工具链
make
make install
三:交叉编译lighttpd
cd ~/work/lighttpd/
mkdir _install
tar zxf lighttpd-1.4.54.tar.gz
cd lighttpd-1.4.54/
./configure --prefix=/home/hfzuo/work/_install/ --host=aarch64-linux-gnu --without-zlib --without-bzip2 PCRE_LIB=/home/hfzuo/work/pcre/_install/lib/libpcre.a CPPFLAGS=-I/home/hfzuo/work/pcre/_install/include CC=aarch64-linux-gnu-gcc
make
make install
四:配置lighttpd 服务
在~/work/lighttpd/_install中创建目录cache、cgi-bin、config、log、sockets、upload、vhosts、webpages,并将源码包中doc/config目录下的conf.d目录、lighttpd.conf和modules.conf复制到lighttpd.install/config
cd ~/work/lighttpd/_instal
mkdir -p cache cgi-bin config log sockets upload vhosts webpages
cp -rf ~/work/lighttpd/lighttpd-1.4.54/doc/config/conf.d ~/work/lighttpd/lighttpd-1.4.54/doc/config/lighttpd.conf ~/work/lighttpd/lighttpd-1.4.54/doc/config/modules.conf ./config
修改lighttpd.conf 如下:(只列出了需要修改的地方)
var.log_root = "/root/lighttpd/log"var.server_root = "/root/lighttpd"var.state_dir = "/root/lighttpd"var.home_dir = "/root/lighttpd"var.conf_dir = "/root/lighttpd/config"var.cache_dir = server_root + "/cache"server.use-ipv6 = "disable"#server.username = "lighttpd"#server.groupname = "lighttpd"server.document-root = server_root + "/webpages"#server.pid-file = state_dir + "/lighttpd.pid"#include "conf.d/access_log.conf"#server.network-backend = "sendfile"#$HTTP["url"] =~ "\.pdf$" {# server.range-requests = "disable"#}server.upload-dirs = ( "/root/lighttpd/upload" )
修改modules.conf 如下:(只列出了需要修改的地方)
server.modules = ( "mod_access", "mod_alias",# "mod_auth",# "mod_authn_file",# "mod_evasive",# "mod_setenv",# "mod_usertrack",# "mod_redirect",# "mod_rewrite",)include "conf.d/cgi.conf"
修改conf.d/cgi.conf 如下:(只列出了需要修改的地方)
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" )alias.url += ( "/cgi-bin" => server_root + "/cgi-bin" )
五:测试网页添加
在_install/webpages目录下创建index.html文件,文件中添加如下内容:
<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>lighttpd Test</title></head><body><p>Hello World!</p><hr><p>Test Page!</p></body></html>
六:lighttpd 服务测试
将~/work/lighttpd/_install 整个文件夹全部拷贝到开发板/root/下 并重命名为lighttpd,此路径为第四步中配置文件设置,可自行修改,检查开发板是否有/var/tmp 目录,没有则新建。
在开发板中:
cd /root/lighttpd/sbin
./lighttpd -f ../config/lighttpd.conf -m ../lib/
在pc端浏览器中输入开发板ip即可弹出网页,如下: