实战 FastCGI_2. 安装 FastCGI之四

**2.3 安装 FastCGI 开发套件

** 1. 下载 fcgi-devkit-2.1.tar.gz 并且解开:
$ gunzip -c fcgi-devkit-2.1.tar.gz | tar xvf -

2. 编译
$ cd fcgi-devkit-2.1
$ ./configure
$ make

3. 将 C 的标头档 (header file) 及函式库 (library) 安装至系统:
$ cp -rp include /usr/local/include/fastcgi
$ cp libfcgi/libfcgi.a /usr/local/lib

2.4 测试 FastCGI

在 fcgi-devkit 套件中内含一个简单的 FastCGI 范例程序 - echo.c,我们用它来做测试系统是否安装正确。直接把已经编译好的 echo.fcg 复制到预设放置 FastCGI 程序的目录下:

$ cd fcgi-devkit-2.1/example
$ cp echo.fcg /usr/local/www/fcgi-bin

现在赶快用浏览器连到 http://localhost/fcgi-bin/echo.fcg 看看,如果看到以下结果表示您大功告成啦:

FastCGIecho
Requestnumber1,ProcessID:1013

Nodatafromstandardinput.

Requestenvironment:
FCGI_ROLE=RESPONDER
DOCUMENT_ROOT=/usr/local/apache/htdocs
HTTP_ACCEPT=text/html,text/plain,application/applefile,application/x-metamai
l-patch,sun-deskset-message,mail-file,default,postscript-file,audio-file,
x-sun-attachment,text/enriched,text/richtext,application/andrew-inset,x-be2
,application/postscript,message/external-body,message/partial,application/p
gp,application/pgp,video/mpeg,video/,image/,audio/,audio/mod,text/sgm
l,video/mpeg,image/jpeg,image/tiff,image/x-rgb,image/png,image/x-xbitmap,
image/x-xbm,image/gif,application/postscript,
/*;q=0.01
HTTP_ACCEPT_ENCODING=gzip,compress
HTTP_ACCEPT_LANGUAGE=en
HTTP_HOST=localhost
HTTP_NEGOTIATE=trans
HTTP_USER_AGENT=Lynx/2.8.1pre.9libwww-FM/2.14
PATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/sbin:/opt/kde/bin:/home/m
yhsu/bin:/usr/X11R6/bin:/usr/sbin:/opt/kde/bin:/usr/X11R6/bin:/usr/sbin:/opt/kd
e/bin
REMOTE_ADDR=127.0.0.1
REMOTE_PORT=1024
SCRIPT_FILENAME=/usr/local/www/fcgi-bin/echo.fcg
[email protected]
SERVER_NAME=localhost.localdomain
SERVER_PORT=80
SERVER_SIGNATURE=

Apache/1.3.6Serveratlocalhost.localdomainPort80

SERVER_SOFTWARE=Apache/1.3.6(Unix)mod_fastcgi/2.2.2
UNIQUE_ID=N1ptln8AAAEAAAPdDRkGATEWAY_INTERFACE=CGI/1.1
SERVER_PROTOCOL=HTTP/1.0REQUEST_METHOD=GETQUERY_STRING=
REQUEST_URI=/fcgi-bin/echo.fcgSCRIPT_NAME=/fcgi-bin/echo.fcg

Initialenvironment:

请注意在以上程序所显示的 Request number 和 Process ID 这两个变量,当我们继续重新加载这支程序时,Request number 会一直累加而 Process ID 的值都不会改变。这表示这支程序在第一次激活之后就一直执行着没有结束,而且在每次联机请求中所参照到的变量空间是相同的 (所以 Request number 会不断加一)。
到此为止,我们已经成功建立起一个可供发展 FastCGI 应用程序的环境及执行 FastCGI 应用程序的网站执行平台。

Published At
Categories with Web编程
Tagged with
comments powered by Disqus