C语言编写cgi程序hello world

来源:互联网 发布:rap编曲知乎 编辑:程序博客网 时间:2024/05/18 08:49

安装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;
}


0 0
原创粉丝点击