标签:
</pre><pre name="code" class="plain">#设置首页 root /usr/share/nginx/myweb; index index.html index.htm; #修改端口 listen 8880 default_server; listen [::]:8880 default_server ipv6only=on; #设置fastcgi程序入口 location /mycgi.cgi { fastcgi_pass 127.0.0.1:9999; -> fastcgi程序监听的端口 #fastcgi_index mycgi.out; include fastcgi_params; }
#include <iostream>
#include <fcgi_stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main(int argc, char** argv)
{
int count = 0;
while( FCGI_Accept() >= 0 )
{
printf( "Content-type:text/html\r\n\r\n" );
printf( "<p> Hello FastCGI ! </ p>" );
printf( "<br /> Request number = [%d]", ++count );
printf( "<br /> CGI PID: %d ", getpid() );
}
return 0;
}
编译
g++ mycgi.c -o mycgi.out -L /usr/local/lib -lfcgi标签:
原文地址:http://blog.csdn.net/ydogg/article/details/46430527