如何配置执行c写的cgi程序

来源:互联网 发布:linux创建txt文件命令 编辑:程序博客网 时间:2024/04/30 04:21
apache配置如下:

ScriptAlias   /cgi-bin/   "C:/Apache2/cgi-bin/"

#
#   "C:/Apache2/cgi-bin"   should   be   changed   to   whatever   your   ScriptAliased
#   CGI   directory   exists,   if   you   have   that   configured.
#
<Directory   "C:/Apache2/cgi-bin" >
        AllowOverride   None
        Options   None
        Order   allow,deny
        Allow   from   all
</Directory >


test.c代码如下:

#include                 <stdio.h >
#include                 <stdlib.h >

int   main(void)
{
    char*   query;

    printf("%s%c%c/n","Content-Type:text/html;charset=iso-8859-1",13,10);
    printf(" <title >Search   Result </title >/n");
    printf(" <H3 >Search   Result </H3 >/n");

    query   =   getenv("QUERY_STRING");

    //   Note   1:   other   functions   to   truncate   the   query   string

    //   Note   2:   other   functions   to   search   for   the   related   documents

    //   Now,   if   you   find   the   word   and   want   to   display   on   user "s   browser,   do

    printf("/n <p >   word   %s   is   found/n",   query);
}


我用MinGW编译程序,把程序放到了

C:/Apache2/cgi-bin/test.exe

但用IE打开:http://localhost/cgi-bin/test.exe

确要我下载.问题出在哪呢?

请各位高手帮忙.     20 
  • xing007008
  • 等 级:
发表于:2007-05-24 15:21:381楼 得分:0 上面的配置已经正确了,只是我当时没有重启动apache.  
  • tipboy
  • 等 级:
发表于:2007-05-29 12:24:352楼 得分:0 exe类型允许访问?  
  • mocom
  • 等 级:
发表于:2007-05-29 12:46:203楼 得分:0 <Directory   "C:/Apache2/cgi-bin" >
        AllowOverride   All
        Options   All
        Order   allow,deny
        Allow   from   all
</Directory >  
  • xing007008
  • 等 级:
发表于:2007-05-30 22:06:144楼 得分:0 是的,允许访问的.
我是在windows平台下做测试的.  
  • netxuning
  • 等 级:
发表于:2007-06-18 15:31:005楼 得分:0 遇上了同样的问题...  
  • hij333
  • 等 级:
发表于:2007-08-07 09:13:196楼 得分:0 httpd中配置的可解析的后缀包含.exe了吗?