lighttpd+fastcgi+Raphters+qdecoder+json-c环境搭建

本文详细介绍了如何搭建lighttpd+fastcgi环境,并结合Raphters web框架进行配置。从lighttpd和fcgi的下载编译到index.html的设置,再到Raphters的安装与前端访问cgi的实现,以及qdecoder和json-c的使用,展示了如何在lighttpd中使用fastcgi和json数据传输。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wit_yuan

专注模块功能分析与架构

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值