开发者

Run fast cgi program through web browser

开发者 https://www.devze.com 2023-03-06 10:45 出处:网络
I have created a hello FastCGI prog in C #include <fcgi_stdio.h> #include <stdlib.h> int count;

I have created a hello FastCGI prog in C

#include <fcgi_stdio.h>
#include <stdlib.h>

int count;
void initialize(void)
{
  count=0;
}
int main(void)
{
  initialize();

  while (FCGI_Accept() >= 0)
  {
    printf("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",
      ++count, getenv("REMOTE_HOST"));
  }
  return 1;
}

Then I compiled the program using "gcc -o hello1 hello1.c -lfcgi"

This created "hello1" executable file in my home directory (in ubuntu) When I ran this file, I got output as:

Content-type: text/html

<title>FastCGI Hello! (C, fcgi_stdio library)</title><h1>FastCGI Hello! (C, fcgi_stdio library)</h1>Request number 1 running on host <i>(null)</开发者_运维知识库i>

I want to run this file from firefox. Since I am new to this, I dont have any idea about it. Can any one, provide me with detailed ans, what all steps I need to follow to run it through web browser. I tried typing the URL as "http://localhost/fcgi-bin/hello1" after copying the 'hello1" file to /etc/apache/fcgi-bin/hello1.fcgi but it gave 404 error


You'd still need to include the .fcgi extension on the url:

http://localhost/fcgi-bin/hello1.fcgi
0

精彩评论

暂无评论...
验证码 换一张
取 消