您的位置:首页 > 编程语言 > C语言/C++

C语言编写cgi程序hello world

2017-02-05 16:16 330 查看
安装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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: