通过网络浏览器运行快速的cgi程序

发布于 2024-11-07 08:48:37 字数 1093 浏览 2 评论 0原文

我用 C 创建了一个 hello FastCGI prog

#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;
}

然后我使用“gcc -o hello1 hello1.c -lfcgi”编译了该程序

这在我的主目录(在 ubuntu 中)中创建了“hello1”可执行文件 当我运行这个文件时,我得到的输出为:

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>

我想从 Firefox 运行这个文件。由于我是新手,所以我对此没有任何想法。任何人都可以为我提供详细的答案,我需要遵循哪些步骤才能通过网络浏览器运行它。 将“hello1”文件复制到 /etc/apache/fcgi-bin/hello1.fcgi 后,我尝试输入 URL“http://localhost/fcgi-bin/hello1”,但出现 404 错误

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

慕烟庭风 2024-11-14 08:48:37

您仍然需要在网址中包含 .fcgi 扩展名:

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

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

http://localhost/fcgi-bin/hello1.fcgi
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文