FastCGI开发学习

FastCGI开发学习http://www.xinze.me/fastcgi%E5%BC%80%E5%8F%91%E5%AD%A6%E4%B9%A0/1.下载fastcgi开发包,编译安装http://www.fastcgi.com/dist/fcgi-current.tar.gz1wgethttp://www.fastcgi.com/dist/fcgi-curren

大家好,又见面了,我是你们的朋友全栈君。

http://www.xinze.me/fastcgi%E5%BC%80%E5%8F%91%E5%AD%A6%E4%B9%A0/

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

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

2 tar zvzf fcgi-current.tar.gz
3 cd fcgi-current
4 ./configure
5 make
6 make install

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

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

2 tar zxvf spawn-fcgi-1.6.0.tar.gz
3 cd spawn-fcgi-1.6.0
4 ./configure
5 make
6 make install

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

01 #include <fcgi_stdio .h="">
02 int main(int argc, char*argv[] )
03 {
04     while( FCGI_Accept() >= 0 ) {
05         printf("Content-Type: text/plain\n\n" );
06         printf("Hello FastCGI\n" );
07     }
08     return0;
09 }
10 </fcgi_stdio>

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

gcc -o hello hello.c -lfcgi

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

01 server {
02             listen   80;
03             server_name _;
04  
05             location / {
06                   root   /home/user/www;
07                   index  index.html;
08                   fastcgi_pass 127.0.0.1:9000;
09             }
10 }

5. 启动hello

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

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

一个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://javaforall.net/157602.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号