⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 asg05.htm

📁 apache技术手册
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<HTML>

<HEAD>

<TITLE>Apache Server Survival Guide asg05.htm </TITLE>

<LINK REL="ToC" HREF="index.htm" tppabs="http://docs.rinet.ru:8080/Apachu/index.htm">

<LINK REL="Index" HREF="htindex.htm" tppabs="http://docs.rinet.ru:8080/Apachu/htindex.htm">

<LINK REL="Next" HREF="asg06.htm" tppabs="http://docs.rinet.ru:8080/Apachu/asg06.htm">

<LINK REL="Previous" HREF="asg04.htm" tppabs="http://docs.rinet.ru:8080/Apachu/asg04.htm"></HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080">
<!--#exec cmd="/www/docs/ssi-bin/restricted_search.ssi"-->





<!--#exec cmd="/www/docs/ssi-bin/inc.ssi"-->






<A NAME="I0"></A>

<H2>Apache Server Survival Guide asg05.htm</H2>

<P ALIGN=LEFT>

<A HREF="asg04.htm" tppabs="http://docs.rinet.ru:8080/Apachu/asg04.htm" TARGET="_self"><IMG SRC="purprev.gif" tppabs="http://docs.rinet.ru:8080/Apachu/purprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A>

<A HREF="index.htm" tppabs="http://docs.rinet.ru:8080/Apachu/index.htm" TARGET="_self"><IMG SRC="purtoc.gif" tppabs="http://docs.rinet.ru:8080/Apachu/purtoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A>

<A HREF="asg06.htm" tppabs="http://docs.rinet.ru:8080/Apachu/asg06.htm" TARGET="_self"><IMG SRC="purnext.gif" tppabs="http://docs.rinet.ru:8080/Apachu/purnext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A>


<HR ALIGN=CENTER>

<P>

<UL>

<UL>

<UL>

<LI>

<A HREF="#E68E35" >What Is a CGI Program?</A>

<LI>

<A HREF="#E68E36" >What Programming Language Should You Use?</A>

<UL>

<LI>

<A HREF="#E69E30" >Perl</A>

<LI>

<A HREF="#E69E31" >C</A>

<LI>

<A HREF="#E69E32" >Shell (sh)</A>

<LI>

<A HREF="#E69E33" >Where to Learn More</A>

<UL>

<LI>

<A HREF="#E70E3" >Perl</A>

<LI>

<A HREF="#E70E4" >CGI</A>

<LI>

<A HREF="#E70E5" >World Wide Web</A>

<LI>

<A HREF="#E70E6" >C and Shell (sh)</A></UL></UL>

<LI>

<A HREF="#E68E37" >Hello World!</A>

<LI>

<A HREF="#E68E38" >Running a CGI Program</A>

<LI>

<A HREF="#E68E39" >Standard Environment Variables</A>

<UL>

<LI>

<A HREF="#E69E34" >AUTH_TYPE</A>

<LI>

<A HREF="#E69E35" >CONTENT_LENGTH</A>

<LI>

<A HREF="#E69E36" >CONTENT_TYPE</A>

<LI>

<A HREF="#E69E37" >GATEWAY_INTERFACE</A>

<LI>

<A HREF="#E69E38" >PATH_INFO</A>

<LI>

<A HREF="#E69E39" >PATH_TRANSLATED</A>

<LI>

<A HREF="#E69E40" >QUERY_STRING</A>

<LI>

<A HREF="#E69E41" >REMOTE_ADDR</A>

<LI>

<A HREF="#E69E42" >REMOTE_HOST</A>

<LI>

<A HREF="#E69E43" >REMOTE_IDENT</A>

<LI>

<A HREF="#E69E44" >REMOTE_USER</A>

<LI>

<A HREF="#E69E45" >REQUEST_METHOD</A>

<LI>

<A HREF="#E69E46" >SCRIPT_NAME</A>

<LI>

<A HREF="#E69E47" >SERVER_NAME</A>

<LI>

<A HREF="#E69E48" >SERVER_PORT</A>

<LI>

<A HREF="#E69E49" >SERVER_PROTOCOL</A>

<LI>

<A HREF="#E69E50" >SERVER_SOFTWARE</A></UL>

<LI>

<A HREF="#E68E40" >Client Header Lines: HTTP_*</A>

<UL>

<LI>

<A HREF="#E69E51" >HTTP_ACCEPT</A>

<LI>

<A HREF="#E69E52" >HTTP_USER_AGENT</A>

<LI>

<A HREF="#E69E53" >HTTP_REFERER</A></UL>

<LI>

<A HREF="#E68E41" >Reading the Environment</A>

<LI>

<A HREF="#E68E42" >Passing Data to a CGI Using the HTTP POST Method </A>

<LI>

<A HREF="#E68E43" >Returning Data from a CGI Program</A>

<UL>

<LI>

<A HREF="#E69E54" >Content-type</A>

<LI>

<A HREF="#E69E55" >Location </A>

<LI>

<A HREF="#E69E56" >Status</A></UL>

<LI>

<A HREF="#E68E44" >Forms </A>

<UL>

<LI>

<A HREF="#E69E57" >Decoding QUERY_STRING </A></UL>

<LI>

<A HREF="#E68E45" >A Generic Form Wrapper for E-mail</A>

<LI>

<A HREF="#E68E46" >Random Data</A>

<UL>

<LI>

<A HREF="#E69E58" >An Image Randomizer</A>

<LI>

<A HREF="#E69E59" >A URL Randomizer</A></UL>

<LI>

<A HREF="#E68E47" >A Bulletin Board</A>

<LI>

<A HREF="#E68E48" >Summary</A></UL></UL></UL>

<HR ALIGN=CENTER>

<A NAME="E66E5"></A>

<H1 ALIGN=CENTER>

<CENTER>

<FONT SIZE=6 COLOR="#FF0000"><B>5</B></FONT></CENTER></H1>

<BR>

<A NAME="E67E8"></A>

<H2 ALIGN=CENTER>

<CENTER>

<FONT SIZE=6 COLOR="#FF0000"><B>CG</B><B>I (Common Gateway Interface) Programming</B></FONT></CENTER></H2>

<BR>

<P>Any Web site that does more than just display pages will use Common Gateway Interface (CGI) programs. CGI programs provide support to many useful functions. Even basic things such as Hypertext Markup Language (HTML) forms require a CGI program to process the information and do something useful with it. Many people refer to CGI programs as <I>scripts</I>. For me, this term somehow diminishes the complexity that some CGI programs have. I prefer to call them CGI programs. CGI programs can exist as interpreted scripts or compiled binaries&#151;in either form, they are programs.

<BR>

<P>The most popular languages used for developing CGI programs are sh (Bourne shell), Perl (Practical Extraction Report Language), and C. You can use any language from which you can access environment variables. Most, if not all, UNIX programming or scripting languages can do this because this support is really inherited from the shells. This means that, depending on the task at hand, you are free to choose a CGI development tool that matches your needs and program complexity&#151;a good thing.

<BR>

<BR>

<A NAME="E68E35"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>What Is a CGI Program?</B></FONT></CENTER></H3>

<BR>

<P>A <I>CGI program</I> is a program that conforms to certain conventions. Many people think that CGI is a protocol or a language or a specification. CGI is none of the above; it is a standard. In simplest terms, CGI is just a set of commonly used variables with the conventions used to access them. The variables provided by the CGI convention are used to exchange information between the HTTP server and a client program. In addition, CGI provides a means to return output to the browser. All output sent to stdout (the standard output stream) by a CGI program shows up on the Web browser, provided the right MIME-type header is sent by the CGI program.

<BR>

<P>If you want to execute a CGI program, you need to run a Web server like Apache because CGI transactions cannot be simulated by the browser. CGI calls happen only on the server side. On execution, most CGI programs will

<BR>

<UL>

<LI>Process data sent by a browser; 

<BR>

<BR>

<LI>Return some sort of data; or

<BR>

<BR>

<LI>Redirect the client to another URL containing some information

<BR>

<BR>

</UL>

<P>At its most basic level, a CGI program will usually collect information from an HTML form, process data in the form, and then perform some action such as e-mailing data to a person. In its most complex form, there are virtually no limits to what can be done with a CGI program. CGI programs can interact with databases by fetching and storing various pieces of information to produce some sort of result.

<BR>

<P>Because of the stateless nature of the World Wide Web, there is no way to track a user from page to page using just conventional document-serving techniques. CGI allows communication, through a standard set of environment variables, between the HTTP server and a program running on the server computer&#151;in this case, a CGI program. All sorts of things are possible with CGI that were not feasible with just HTML.

<BR>

<P>This basic capability of sending some data to a program via an HTTP server is responsible for a whole new way of creating client/server&#150;type applications: the intranet. CGI programs permit the content of Web pages to be dynamic and relevant to what the user wants to see. I believe that in the future, many custom applications developed for private use by an organization (mission-critical applications) will be deployed as intranets&#151;as Web-based applications. It makes sense. Instead of developing various versions of a program to match the mixed environment of today's office&#151;PC, Macintosh, UNIX&#151;you can develop a single version of your application that resides on a Web server. As long as there's a browser available for the machine you are using, you can access the application. Obviously, there are limitations, and some things are better done on the client side anyway. Java and other client-side programming tools will allow for more complex user-interface portions of the software to reside on the client, while the data persistence and other functionality happens on the server side.

<BR>

<P>Some environments, such as WebObjects from NeXT Software, Inc., provide many of the tools needed to create complex, real-world, Web-based applications today.

<BR>

<BR>

<A NAME="E68E36"></A>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -