一般的网关接口或者CGI,就是一个标准的集合。它定义信息怎样再问吧server和一般脚本间的交换。

CGI的说明书是由NCSA维护,NCSA定义CGI的范畴:一般的网关接口或者CGI是外部网关程序的一个标准,它与信息server交互。当前的CGI版本号是CGI/3.2.9,兴许版本号还在开发中。

一般的网关程序(CGI)是一个标准协议,它可以使应用程序(称之为CGI程序或者CGI脚本)与Webserver和client进行交互。

这些CGI程序可以使用Python、PERL、Shell,C或者C++等编写。

以下介绍一个实例,依据这个实例来说明,怎样使用CGI。

首先,必须配置HTTPserver,这里。我们选择ApacheHttpd作为HTTP协议的server。CGI设置例如以下:

#change the directoryRootvariable in httpd.conf file
DocumentRoot"/usr/local/apache-2.4.9/htdocs"
#set theaccess control
<Directory"/usr/local/apache-2.4.9">

#enable the cgi module
LoadModule cgid_module modules/mod_cgid.so
#set the directoryproperties
<Directory "/usr/local/apache-2.4.9/cgi-bin">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory> <Directory "/usr/local/apache-2.4.9/cgi-bin">
Options All
</Directory>

编写一个C++的CGI程序,并编译它得到cpp.cgi文件。改变这个文件的全部权限,使用命令“chmod 755 cpp.cgi”。

cpp.cpp文件

#include <iostream>
using namespace std; int main ()
{ cout << "Content-type:text/html\r\n\r\n";
cout << "<html>\n";
cout << "<head>\n";
cout << "<title>C++ CGI Welcome you</title>\n";
cout << "</head>\n";
cout << "<body>\n";
cout << "<h2>Congratulation, you enter into the world of CGI.</h2>\n";
cout << "</body>\n";
cout << "</html>\n"; return 0;
}

将编译后的cgi文件放置指定的路径(/usr/local/apache-2.4.9/cgi-bin)下。启动httpd服务。浏览页面:

http://hadoop-master/cgi-bin/cpp.cgi

版权声明:本文博客原创文章。博客,未经同意,不得转载。

C++ Web Programming的更多相关文章

  1. Introduction to ASP.NET Web Programming Using the Razor Syntax (C#)

    1, http://www.asp.net/web-pages/overview/getting-started/introducing-razor-syntax-c 2, Introduction ...

  2. Web开发中最致命的8个小错误

    错误1:表单的label标签跟表单字段没有关联 利用“for”属性允许用户单击label也可以选中表单中的内容.这可以扩大复选框和单选框的点击区域,非常实用. 错误2:logo图片没有链接到主页 点击 ...

  3. java web 学习 --第十天(Java三级考试)

    第九天学习内容:http://www.cnblogs.com/tobecrazy/p/3470195.html 需求概述 创建程序模块,读取并显示数据库中的书籍信息.当前有如下需求:需要显示数据库中所 ...

  4. web server && web framework角色区分

    问题 web framework是否包括webserver? 是否可以包括? webserver 和 framework的关系是? https://www.quora.com/What-is-the- ...

  5. [译]如何在Web开发中使用Python

    [译]如何在Web开发中使用Python 原文:HOWTO Use Python in the Web 摘要 这篇文档展示了Python如何融入到web中.它介绍了几种Python结合web服务器的方 ...

  6. Go Web:处理请求

    处理请求 Request和Response http Requset和Response的内容包括以下几项: Request or response line Zero or more headers ...

  7. Go Web:Cookie

    Cookie用来解决http协议无状态的问题. 首先,在服务端生成Cookie,然后在http响应header中设置Set-Cookie字段,客户端会读取到Set-Cookie字段后,会将cookie ...

  8. Mercedes offline programming/coding tips and guides

    Mercedes offline programming/coding recommendations and guides: Offline coding: SCN or CVN coding wa ...

  9. Programming Languages: Application and Interpretation

    http://cs.brown.edu/courses/cs173/2012/book/ 1 Introduction 1.1 Our Philosophy 1.2 The Structure of ...

随机推荐

  1. 15一个NoSql数据库

    随着因特网web2.0该网站的兴起.非关系型数据库,现在已经成为一个非常受欢迎的新领域.非关系数据库产品的发展非常迅速.而在处理传统的关系数据库web2.0现场.特别是大规模,高并发SNS类型web2 ...

  2. cocos2dx 遮罩层 android 手机上 失败

    1.CCClippingNode使用(在模拟器上ok,在手机上不行),实现多个剪切区域 local layer=CCLayerColor:create(ccc4(0,0,0,110))     --/ ...

  3. PhoneGap 开发与应用 上传 App Store 在

    几个简单的归纳过程,前提是你有一个开发者账户,而且必须有Mac 虚拟机或真机.尽管WIndows 也可以上载证书.但最终也必须用于上传应用程序 Xcode 要么  Application Loader ...

  4. CopyOnWriteArrayList源代码阅读器

    java.util.concurrent在相应的并发集合的包中定义的通用集合类,为了有效地处理并发场景.间CopyOnWriteArrayList它是合适ArrayList.顾名思义CopyOnWri ...

  5. 安装github for windows问题解决

    到官网下载windows环境下的github,在安装时出现下面问题 An error occurred trying to download 'http://github-windows.s3.ama ...

  6. HDU 5050 Divided Land(进制转换)

    题意  给你两个二进制数m,n   求他们的最大公约数  用二进制表示  0<m,n<2^1000 先把二进制转换为十进制  求出最大公约数  再把结果转换为二进制  数比較大要用到大数 ...

  7. 【UML】概念、关联、画画(一)

    最近画UML画画,于UML观看视频后还没有学会.它是的结果UML九图是不是太懂,我想加深绘制过程的理解,我一个新的水平. 现在我觉得是时候..地介绍一下UML.了解一下它的基本内容.达到深入浅出的效果 ...

  8. LeetCode——Add Binary

    Given two binary strings, return their sum (also a binary string). For example, a = "11" b ...

  9. .net RPC框架选型(一)

    近期开始研究分布式架构,会涉及到一个最核心的组件:RPC(Remote Procedure Call Protocol).这个东西的稳定性与性能,直接决定了分布式架构系统的好坏.RPC技术,我们的产品 ...

  10. LeetCode Solutions : Reorder List

    →-→Ln-1→Ln, reorder it to: L→Ln-2→- You must do this in-place without altering the nodes' values. Fo ...