lighttpd1.4.20源码分析:安装与配置

简介: lighttpd1.4.20源码分析:安装与配置

1、有两种渠道下载源码,分别是:


http://www.lighttpd.net/download/ -- 官网

https://github.com/lighttpd -- GitHub


官网下载的源码和GitHub的略有不同,我们以前者,也就是官网的为准。



2、我们下载版本lighttpd-1.4.20.tar.gz,解压之后发现它是make版本,没有cmake文件。我们从GitHub v1.4.21版本拉取,github上面的源码是带有cmakelists文件的(从v1.4.21版本开始)。整合之后,就可以实现lighttpd-1.4.20的cmake编译。


记得修改一处:/src/CMakeLists.txt,第471行,因为官网1.4.20的源码没有mod_uploadprogress.c文件


#ADD_AND_INSTALL_LIBRARY(mod_uploadprogress mod_uploadprogress.c)


完整的cmake工程源码请见:


https://download.csdn.net/download/libaineu2004/10843267



3、使用IDE Qt Creator来编译源码。编译完成会在路径生成可执行文件:


build-lighttpd-1.4.20-cmake-Desktop_Qt_5_9_7_GCC_64bit-Debug/build/lighttpd


及一系列的*.so的插件库文件。


终端命令行,启动lighttpd的方法是:


[root@localhost build]# ./lighttpd -D -f lighttpd.conf -m .


其中-D表示调试模式,非守护进程运行;


     -f lighttpd.conf表示指定的配置文件;


    -m .表示指定的*.so库文件路径,这里的"."表示so文件都在当前路径。


注意,每次运行必须指明库文件*.so的路径,否则会报错:


mod_indexfile.so: cannot open shared object file: No such file or directory



4、lighttpd.conf几个重要的配置项


#代表网站存放的路径

server.document-root             = "/home/firecat/"
## where to send error-messages to 错误日志的路径
server.errorlog            = "/var/log/lighttpd/error.log"
#firecat建议注释掉chroot/username/groupname这三项
### only root can use these options
#
# chroot() to directory (default: no chroot() )
#server.chroot            = "/"
## change uid to <uid> (default: don't care)
#server.username            = "www-data"
## change uid to <uid> (default: don't care)
#server.groupname           = "www-data"
#守护进程的文件名
server.pid-file              = "/var/run/lighttpd.pid"
# files to check for if .../ is requested
server.indexfiles          = ( "index.php", "index.html",
                                "index.htm", "default.htm" )


5、运行测试


编写一个简单的网页,另存为index.html文件,utf-8格式


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>lighttpd测试</title>
</head>
<body>
<p>轻量级web服务器lighttpd的编译及配置(for x86-linux)</p>
<hr>
<p>测试页面</p>
</body>
</html>

然后拷贝到Linux路径/home/firecat/


启动Lighttpd服务器,在浏览器输入http://127.0.0.1/,即可输出:



相关文章
|
4月前
|
前端开发 Java 应用服务中间件
Tomcat 软件和配置文件 基本介绍
Tomcat 软件和配置文件 基本介绍
|
11月前
|
域名解析 存储 网络协议
Nginx之配置文件及基础概念解读
Nginx之配置文件及基础概念解读
|
tengine 应用服务中间件 网络安全
nginx学习(核心配置详解)
nginx学习(核心配置详解)
155 0
|
存储 应用服务中间件 测试技术
Nginx反向代理工作原理简介与配置详解
Nginx反向代理工作原理简介与配置详解
292 0
|
存储 负载均衡 安全
Nginx/Tomcat/Apache的优缺点和区别
Nginx/Tomcat/Apache的优缺点和区别
351 0
|
Web App开发 存储 缓存
|
Web App开发 应用服务中间件 测试技术
|
Web App开发 应用服务中间件 网络安全
|
Web App开发 JavaScript 应用服务中间件