简介
lighttpd是一款轻量级的开源WEB服务器,跟Apache、Nginx功能差不多。
下载
对应的官网http://www.lighttpd.net/,目前下载到的最新版本是lighttpd-1.4.58.tar.gz。
编译与安装
解压:
tar -xzvf lighttpd-1.4.58.tar.gz
配置:
./configure --prefix=/usr/local/lighttpd --without-pcre
第一个参数是指定程序存放路径,第二个参数是不使用Perl兼容性正则表达式。configure的时候可能会报错,因为缺少某些库,比如本次配置少了zlib,安装zlib1g-dev即可。
编译:
make
安装:
sudo make install
安装成功之后:

配置
首先是一个最简单的配置文件:
server.document-root = "/home/jw/code/www/html"
server.bind = "localhost"
server.port = 80
mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".jpg" => "image/jpeg",
".png" => "image/png"
)
static-file.exclude-extensions = ( ".fcgi", ".php", ".rb", "~", ".inc" )
index-file.names = ( "index.html" )
使用
配置完成之后,还需要在/home/jw/code/www/html/目录下创建index/html文件:
<html>
<body>
Hello Wolrd!
</body>
</html>
之后就可以执行lighttpd开启服务器:
root@X1C:/usr/local/lighttpd/sbin# ./lighttpd -D -f test.conf
2021-01-27 00:07:01: server.c.1508) server started (lighttpd/1.4.58)
得到的结果:

以上是lighttpd服务器的基础。
本文介绍了lighttpd这款轻量级开源WEB服务器的下载、编译安装过程及基本配置方法,并通过实例演示如何启动lighttpd服务器。

1721

被折叠的 条评论
为什么被折叠?



