我为FastCGI编译了C++项目,将可执行文件复制到www目录,通过浏览器打开-并收到500错误(超时异常)。我怎么了

操作系统Ubuntu 10.05,服务器:Apache

C++源代码:

#include <fcgi_stdio.h> /* fcgi library; put it first*/
#include <fcgiapp.h>
#include <cstdlib>
#include <iostream>

using namespace std;
int count;

int main(int argc, char** argv) {


    /* Response loop. */
      while (FCGI_Accept() >= 0)   {
        cout<<"Content-type: text/html\r\n"
               "\r\n"
               "<title>FastCGI Hello! (C, fcgi_stdio library)</title>"
               "<h1>FastCGI Hello! (C, fcgi_stdio library)</h1>"
               "Request number %d running on host <i>%s</i>\n";
      }
    return 0;
}

最佳答案

当您进入FCGI_Accept()循环时,您应该正在读取数据,而不是写入数据。

查看http://www.fastcgi.com/devkit/doc/fastcgi-prog-guide/apaman.htm

关于c++ - FastCGI,Apache和C++,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8848873/

10-11 21:24