简体   繁体   English

使用Nginx设置fastcgi

[英]Setting up fastcgi with nginx

I am using following c code 我正在使用以下C代码

#include <fcgi_stdio.h>

/*
 * 
 */
int main(int argc, char** argv) {
    while (FCGI_Accept() >= 0) {
        printf("Content-Type: text/plain\r\n");
        printf("Hello world in C\n");
    }

    return 0;
}

I am using following command 我正在使用以下命令

 spawn-fcgi -a127.0.0.1 -p9000 -n ./a.out

Where spawn-fcgi , I installed using fedora 15 repo. 在spawn-fcgi处,我使用fedora 15 repo安装。

Nginx config is: Nginx配置为:

   location / {
        root html;
        fastcgi_pass 127.0.0.1:9000;
        }

I am getting following error: 我收到以下错误:

2012/02/13 16:15:45 [error] 17998#0: *1 upstream closed prematurely FastCGI stdout while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /hello HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1:8081"

What can be wrong ? 有什么问题吗?

Got the issue code should be 得到的问题代码应该是

int main(int argc, char** argv) {
    while (FCGI_Accept() >= 0) {
        printf("Content-Type: text/plain\r\n\r\n");
        printf("Hello world in C\n");
    }

    return 0;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM