当前位置:web 服务器 > Apache >>

apache加VC++ 如何搭建支持C++的cgi

apache加VC++ 如何搭建支持C++的cgi 请高手们帮忙~ 小弟万分感谢,现在没有分,如果又分了散个大家!
补充:我这样弄了,也访问不了啊!
报错以下错误!
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, hehanjm@163.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.
答案:需要注意的有两点

第一 输出的第一行必须是空行
第二 必须在apache的配置文件里面允许
ScriptAlias /cgi-bin/ "E:/apache2/Apache2/cgi-bin/"
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all

AddHandler cgi-script .exe .pl .cgi

1)"E:/apache2/Apache2/cgi-bin/"为你安装的apache下的agi-bin目录,父目录与子目录之间用/分开
其他:很简单啊。

CGI就是从标准输入(POST方式)或环境变量(GET方式)读参数,然后输出到标准输出的方式。ASP、JSP、PHP都是CGI的封装而已。

1.安装配置APACHE;
2.EXE的CGI一般不需要额外的配置,只需要把exe文件拷贝到Apache下的cgi-bin目录下,即可运行。 
URL如下:   http://localhost/cgi-bin/filename.exe/ 
3.用C++写个EXE。
 其实用C都可以写一个。比如下面的:
#include <stdio.h>
int main()
{
printf("Content-type:text/html\n\n");
printf("hello");
}
只是简单的输出一个 hello 

编译成HELLO.EXE,丢过去。

访问
http://localhost/cgi-bin/HELLO.EXE/ 

就可以看到了 

上一个:"为什么CGI程序运行不了,受何限制?
下一个:新手初学Apache服务配置遇到的CGI问题请教大家指点!

Apache
IIS
Nginx
Tomcat
如果你遇到web 服务器难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,