




















spawn-fcgi能够识别自定义的demo下载fcgi:wget ftp://ftp.ru.debian.org/gentoo-distfiles/distfiles/fcgi-2.4.1-SNAP-0910052249.tar.gz
解压安装包:tar -xvf fcgi-2.4.1-SNAP-0910052249.tar.gz
修改文件
find . -name fcgio.hvim ./include/fcgio.h#include <cstdio>在fcgi-2.4.1-SNAP-0910052249目录下执行:./configure
然后顺序执行命令:make、make install
.c结尾的文件,代码如下#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <fcgi_stdio.h>
int main() {
int count = 0;
while(FCGI_Accept() >= 0) {
printf("Content-type: text/html\r\n"
"\r\n"
""
"Hello Badou EveryBody!!!"
"Request number %d running on host %s "
"Process ID: %d\n ", ++count, getenv("SERVER_NAME"), getpid());
}
return 0;
}
编译c文件,命令:g++ -g -o test test.c -lfcgi,编译之后会产生同名的编译文件
运行编译文件test可能提示找不到lib库,修改ld.so.conf文件,然后执行命令ldconfig命令
vim /etc/ld.so.confinclude ld.so.conf.d/*.conf
/usr/include/boost/
/usr/local/lib/
ldconfig运行编译后的文件,命令:./test
打印结果
Hello Badou EveryBody!!!
Request number 1 running on host (null) Process ID: 36010
/usr/local/src/nginx/sbin/spawn-fcgi -a 127.0.0.1 -p 8088 -f /test/thrift_test/cgi_demo/test,之后会提示:spawn-fcgi: child spawned successfully: PID: 36213,然后使用命令:netstat -antup | grep 8088查看端口是否被监听此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。