通过网络浏览器运行快速的cgi程序
我用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您仍然需要在网址中包含
.fcgi
扩展名:You'd still need to include the
.fcgi
extension on the url: