📄 fcgi-devel-kit.htm
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><HTML> <HEAD> <TITLE> FastCGI Developer's Kit </TITLE><STYLE TYPE="text/css"> body { background-color: #FFFFFF; color: #000000; } :link { color: #cc0000 } :visited { color: #555555 } :active { color: #000011 } h5.c3 {text-align: center} h3.c2 {text-align: center} p.c1 {text-align: center}</STYLE> </HEAD> <BODY> <P CLASS="c1"> <IMG BORDER="0" SRC="../images/fcgi-hd.gif" ALT="[[FastCGI]]"><BR CLEAR="all"> </P> <H3 CLASS="c2"> FastCGI Developer's Kit </H3> <!--Copyright (c) 1996 Open Market, Inc. --> <!--See the file "LICENSE.TERMS" for information on usage and redistribution--> <!--of this file, and for a DISCLAIMER OF ALL WARRANTIES. --> <P CLASS="c1"> Mark R. Brown<BR> Open Market, Inc.<BR> </P> <P CLASS="c1"> Document Version: 1.08<BR> 11 June 1996<BR> </P> <H5 CLASS="c3"> Copyright © 1996 Open Market, Inc. 245 First Street, Cambridge, MA 02142 U.S.A.<BR> Tel: 617-621-9500 Fax: 617-621-1703 URL: <A HREF= "http://www.openmarket.com/">http://www.openmarket.com/</A><BR> $Id: fcgi-devel-kit.htm,v 1.6 2002/02/25 00:42:59 robs Exp $<BR> </H5> <HR> <UL TYPE="square"> <LI> <A HREF="#S1">1. Introduction</A> </LI> <LI> <A HREF="#S2">2. Getting started</A> </LI> <LI> <A HREF="#S3">3. Writing applications</A> <UL TYPE="square"> <LI> <A HREF="#S3.1">3.1 Using the <TT>fcgi_stdio</TT> library</A> </LI> <LI> <A HREF="#S3.2">3.2 Using the <TT>fcgiapp</TT> library</A> </LI> <LI> <A HREF="#S3.3">3.3 Using Perl and Tcl</A> </LI> <LI> <A HREF="#S3.4">3.4 Using Java</A> </LI> </UL> </LI> <LI> <A HREF="#S4">4. Running applications</A> <UL TYPE="square"> <LI> <A HREF="#S4.1">4.1 Using a Web server that supports FastCGI</A> </LI> <LI> <A HREF="#S4.2">4.2 Using <TT>cgi-fcgi</TT> with any Web server</A> </LI> </UL> </LI> <LI> <A HREF="#S5">5. Known problems</A> </LI> <LI> <A HREF="#S6">6. Getting support</A> </LI> </UL> <HR> <H3> <A NAME="S1">1. Introduction</A> </H3> <P> FastCGI is an open extension to CGI that provides high performance for all Internet applications without the penalties of Web server APIs. </P> <P> FastCGI is designed to be layered on top of existing Web server APIs. For instance, the <TT>mod_fastcgi</TT> Apache module adds FastCGI support to the Apache server. FastCGI can also be used, with reduced functionality and reduced performance, on any Web server that supports CGI. </P> <P> This FastCGI Developer's Kit is designed to make developing FastCGI applications easy. The kit currently supports FastCGI applications written in C/C++, Perl, Tcl, and Java. </P> <P> This document: </P> <UL TYPE="square"> <LI> Describes how to configure and build the kit for your development platform. </LI> <LI> Tells how to write applications using the libraries in the kit. </LI> <LI> Tells how to run applications using Web servers that support FastCGI or using any Web server and <TT>cgi-fcgi</TT>. </LI> </UL> <P> The kit includes a <A HREF="fastcgi-whitepaper/fastcgi.htm">technical white paper</A>, <TT>doc/fastcgi-whitepaper/fastcgi.htm</TT>. You should read at least the first three sections of the technical white paper before starting to write FastCGI applications. The <A HREF="fcgi-perf.htm">performance paper</A> will help you understand how application design affects performance with FastCGI. </P> <P> The <A HREF="fcgi-spec.html">FastCGI Specification</A>, <TT>doc/fcgi-spec.html</TT>, defines the interface between a FastCGI application and a Web server that supports FastCGI. The software in the kit implements the specification. You don't need to read the specification in order to write applications. </P> <P> Additional information is provided in the <A HREF="http://fastcgi.com/docs/faq.html">FAQ</A> document, which contains frequently asked questions about application development using FastCGI, as well as some general information. </P> <P> Experience with CGI programming will be extremely valuable in writing FastCGI applications. If you don't have enough experience with CGI programming, you should read one of the popular books on the topic or study the <A HREF="http://hoohoo.ncsa.uiuc.edu/cgi/">NCSA CGI page</A>. For a more formal treatment of CGI/1.1 see the <A HREF="http://cgi-spec.golux.com/">Internet Draft CGI 1.1 Specification</A>. </P> <H3> <A NAME="S2">2. Getting started</A> </H3> <P> The kit is a compressed tar (tar.Z) file, distributed via the <A HREF="http://fastcgi.com/">fastcgi.com</A> Web page. Unpacking the tar file creates a new directory <TT>fcgi-devel-kit</TT>. </P> <P> Open the kit's index page, <TT>fcgi-devel-kit/index.html</TT>, using the "Open File" command in your Web browser. The index page gives you an overview of the kit structure and helps you navigate the kit. The index page also contains links that run some example applications, but the applications won't work when index.html is opened using the "Open File" command because they aren't aren't being accessed through a Web server. </P> <P> In order to use the kit in earnest you'll need a Web server that you control, a Web server running with your user ID. The Web server will be starting FastCGI applications that you will need to debug; this will be a lot more convenient for you if these processes run with your user ID. It is best to have a Web server that supports FastCGI. <A HREF="#S4">Section 4</A> discusses Web server issues. </P> <P> If you can, keep the kit on a file system accessible from your personal workstation, do your builds on your workstation, and run your Web server on your workstation. If that's not possible, arrange a configuration such that the kit is accessible from the machine that's going to run your Web server, and build the kit and your applications on a machine that's configured exactly the same way (same processor architecture, operating system, etc.) as the machine that's going to run your Web server. </P> <P> To build the kit you execute this sequence of commands in the <TT>fcgi-devel-kit</TT> directory: </P><PRE> % ./configure % make</PRE> <P> We've built and exercised the kit on these platforms (listed in alphabetical order): </P> <UL TYPE="square"> <LI> BSD/OS 1.1 (Intel Pentium), gcc </LI> <LI> Digital UNIX V3.2 148 (Alpha), gcc/cc </LI> <LI> Hewlett-Packard HP-UX A.09.05 C and B.10.01 A (PA-RISC), gcc/cc </LI> <LI> IBM AIX 1 4 (RS/6000), gcc </LI> <LI> Silicon Graphics IRIX 5.3 11091812 (MIPS), gcc </LI> <LI> Sun Solaris 2.4 and 2.5 (SPARC), gcc/cc </LI> <LI> Sun SunOS 4.1.4 (SPARC), gcc </LI> </UL> <P> Once you've built the kit, follow the directions in <A HREF="#S4">Section 4</A> to bring up your Web server and run the example applications. </P> <H3> <A NAME="S3">3. Writing applications</A> </H3> <H4> <A NAME="S3.1">3.1 Using the <TT>fcgi_stdio</TT> library</A> </H4> <P> The <TT>fcgi_stdio</TT> library provides the easiest transition for C CGI programs and C CGI programmers to FastCGI. Using this library your application can run using either CGI or FastCGI, with the same binary for both situations. </P> <P> To introduce the <TT>fcgi_stdio</TT> library we give a pair of examples: a tiny CGI program and the translation of this program to FastCGI. These two example programs are included in the kit. </P> <P> The CGI program is <TT>examples/tiny-cgi.c</TT>: </P><PRE> #include <stdio.h> #include <stdlib.h> void main(void) { int count = 0; printf("Content-type: text/html\r\n" "\r\n"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -