C语言的FastCGI与Nginx的

编程入门 行业动态 更新时间:2024-10-26 23:37:37
本文介绍了C语言的FastCGI与Nginx的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图运行用Nginx的网络服务器后面C语言的FastCGI应用程序。 Web浏览器永远不会完成加载和响应永远不会完成。我不知道如何处理它和调试。任何有识之士将AP preciated。

Hello World应用程序从fastcgi抽取并简化看起来是这样的:

的#includefcgi_stdio.h#包括LT&;&stdlib.h中GT;INT主要(无效){ 而(FCGI_Accept将> = 0) {  的printf(内容类型:text / html的\\ r \\ n状态:200 OK \\ r \\ n \\ r \\ n); }  返回0;}

输出的可执行文件与任何一个执行:

  

CGI-FCGI -connect 127.0.0.1:9000的a.out

  

产卵-FCGI -a120.0.0.1 -p9000 -n ./a.out

Nginx的配置是:

服务器{        听80;        服务器名称 _; 位置 / {                        #主机和端口的FastCGI服务器                        根/ home / user中/ WWW;                        指数的index.html;                        fastcgi_pass 127.0.0.1:9000; }}

解决方案

您需要调用 FCGI_Accept将在,而循环:

而(FCGI_Accept将()> = 0)

您有 FCGI_Accept将> = 0 在code。我认为,导致 FCGI_Accept将函数的地址进行比较,以 0 。由于功能存在,该比较是从未假的,但不被调用的功能。

I am attempting to run a fastcgi app written in C language behind the Nginx web server. The web browser never finishes loading and the response never completes. I am not sure how to approach it and debug. Any insight would be appreciated.

The hello world application was taken from fastcgi and simplified to look like this:

#include "fcgi_stdio.h" #include <stdlib.h> int main(void) { while(FCGI_Accept >= 0) { printf("Content-type: text/html\r\nStatus: 200 OK\r\n\r\n"); } return 0; }

Output executable is executed with either one of:

cgi-fcgi -connect 127.0.0.1:9000 a.out

or

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

Nginx configuration is:

server { listen 80; server_name _; location / { # host and port to fastcgi server root /home/user/www; index index.html; fastcgi_pass 127.0.0.1:9000; } }

解决方案

You need to call FCGI_Accept in the while loop:

while(FCGI_Accept() >= 0)

You have FCGI_Accept >= 0 in your code. I think that results in the address of the FCGI_Accept function being compared to 0. Since the function exists, the comparison is never false, but the function is not being invoked.

更多推荐

C语言的FastCGI与Nginx的

本文发布于:2023-08-05 11:21:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1305203.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:语言   FastCGI   Nginx

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!