nginx+fast-cgi+c

1. 下载fastcgi开发包,编译安装

http://www.fastcgi.com/dist/fcgi-current.tar.gz

 

#wget http://www.fastcgi.com/dist/fcgi-current.tar.gz #tar zvzf fcgi-current.tar.gz#cd fcgi-current#./configure#make#make install

2. 下载spawn-fcgi,编译安装

http://www.lighttpd.net/download/spawn-fcgi-1.6.0.tar.gz

#wget http://www.lighttpd.net/download/spawn-fcgi-1.6.0.tar.gz #tar zxvf spawn-fcgi-1.6.0.tar.gz#cd spawn-fcgi-1.6.0#./configure#make #make install

3. 编写测试的c fastcgi代码,存为 hello.c

#include <fcgi_stdio.h> int main( int argc, char *argv[] ){ while( FCGI_Accept() >= 0 ) { printf( "Content-Type: text/plain\n\n" ); printf( "Hello world in C\n" ); } return 0;}

编译c源文件,运行时有可能会报找不到lib包,这里我复制了一份,也可以做一个软链接。我这里用的是64位的机器,所以复制到了:/usr/lib64,32位的用:/usr/lib。

 

gcc -o hello hello.c -lfcgi

4. 修改nginx.conf配置文件,重新启动nginx

server { listen 80; server_name _; location / { root /home/user/www; index index.html; fastcgi_pass 127.0.0.1:9000; }}

5. 启动hello

spawn-fcgi -a127.0.0.1 -p9000 -n ./hello

 

6. 访问nginx服务器,浏览器就会输出:Hello world in C

一个nginx c fastcgi学习环境搭建完毕。

 

fastcgi 开发学习资料:

FastCGI中文参考手册
http://man.lupaworld.com/content/develop/Perl/FastCGI_handbook_cn.pdf

Nginx下配置FastCGI
http://202.108.59.116/docs/Nginx%CF%C2%C5%E4%D6%C3FastCGI.pdf

 

转载于:https://www.cnblogs.com/xiatian1071/p/3522919.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值