我试图运行用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的
发布评论