lighttpd+fastcgi+Raphters+qdecoder+json-c环境搭建
1. lighttpd+fastcgi
这里简单介绍一下lighttpd+fcgi开发流程,也就是开篇文章。
1.1 资源下载与编译
1.1.1 lighttpd+fcgi资源下载
lighttpd下载地址(提取码:2sbq)
fcgi下载地址(提取码:g9r8)
1.1.2 lighttpd+fcgi编译安装
安装系统的基本环境配置如下:
ubuntu20.04 64bit
安装lighttpd
步骤:
$ sudo apt-get install libpcre3 libpcre3-dev
$ sudo apt-get install zlib1g-dev
$ sudo apt-get install libbz2-dev
$ cd <lighttpd目录>
$ ./configure
$ make
$ sudo make install
配置lighttpd
:
1.注释<
lighttpd目录
>/doc/config/lighttpd.conf:
#server.username = "lighttpd"
#server.groupname = "lighttpd"
#server.use-ipv6 = "enable"
2.创建文件
$ sudo mkdir /var/log/lighttpd
$ sudo touch /var/log/lighttpd/error.log
3.配置lighttpd.conf,设置网站的根目录
server.document-root = "/var/www"
server.port = 8081
安装fastcgi
步骤:
$ ./configure
$ make
$ sudo make install
安装成功之后,可以找到相关的bin文件:/usr/local/bin/cgi-fcgi
1.1.3 index.html
lighttpd
默认使用的网页是index.html
。
1.1.4 运行lighttpd进程
$ sudo lighttpd -f <lighttpd目录>doc/config/lighttpd.conf
停止lighttpd进程
:
$ killall lighttpd
1.1.5 访问lighttd服务
首先需要在上面配置的/var/www
中添加index.html
,内容可以自己编辑,例如写入:
"hello world"
在浏览器中输入:http://127.0.0.1:8081/
,可以看到如下界面内容:
1.1.5 使用fastcgi访问方法
1.配置lighttpd.conf文件
添加如下内容:
server.modules += ("mod_fastcgi")
fastcgi.debug = 1
fastcgi.server += ("/api" =>
((
"bin-path" =>
"/usr/local/bin/fcgi_test",
"max-procs" => 1,
"socket" =>
"/tmp/fcgi_test.socket",
"check-local" => "disable",
"allow-x-send-file" => "enable"
)))
2.参考链接
3.使用如下cgi程序:test.c
#include <stdlib.h>
#include <string.h>