安装apache服务器,配置httpd.conf文件如下:
# "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/cgi-bin" should be changed
to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/cgi-bin">
AllowOverride None
# Options None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
AddHandler cgi-script .exe .pl .cgi //运行.exe/.pl/.cgi程序
Example:
#include "stdafx.h"
#include "stdlib.h"
int main(int argc, char* argv[])
{
printf("Content-Type:text/html; charset=gb2312;\n\n");//后面必须加两个回车
printf("<html>");
printf("<body>");
printf("hello world!");
printf("</body>");
printf("</html>");
return 0;
}