Installing FastCGI in Unix/Linux is complicated. Now let's talk about FastCGI installation in Unix/Linux, Perl, and Apache server environments.
FCGI modules in Apache:
1. Download http://www.fastcgi.com/dist/mod_fastcgi.tar.gz
2. decompress the apache installation file. Decompress the fastcgi Installation File to/src/modules/fas under apache.
Tcgi directory
3. Set Apache to add the mod_fastcgi module:
./Configure -- activate-module = src/modules/fastcgi/libfastcgi. a -- enabl
E-module = info -- enable-shared = info
4. Compilation and Installation
$ Make
$ Make install
5. Check whether the compiled execution file contains the mod_fastcgi module:
$ Apacherunpath/httpd-l
Compiled-in modules:
Http_core.c
...
Mod_fastcgi.c
...
6. Add relevant settings for using mod_fastcgi www.linuxidc.com
Edit httpd. conf and add AddHandler fastcgi-script. fcg. fpl.
Create the youwwwpath/fcgi-bin directory and set the/fcgi-bin/directory to indicate youwwwpath/fcgi-bin.
/Add ScriptAlias/fcgi-bin // usr/local/www/fcgi-bin/to httpd. conf/
7. Check for syntax errors
$/Apachepath/apachectl configtest
Syntax OK -- system display
8. reactivate the Apache server to make the new settings take effect:
$/Usr/local/apache/sbin/apachectl graceful
/Usr/local/apache/bin/apachectl graceful: httpd gracefully restarted
-- System display
FCGI module of PERL:
1. First, we install the FastCGI module in Perl. The latest version in http://www.fastcgi.com
.
Latest: FCGI-0.56.tar.gz
2. Download FCGI-0.45.tar.gz and unlock
$ Gunzip-c FCGI-0.56.tar.gz | tar xvf-
3. Compilation and Installation
$ Perl Makefile. PL
$ Make
$ Make install
4. Test
$ Cp echo. fpl {directory where Fastcgi is located in your www}
$ Lynx {echo. fpl address in your www}
If it succeeds, the following results will be displayed:
FastCGI echo (Perl)
Request number 1
No data from standard input.
Request environment:
DOCUMENT_ROOT =/usr/local/apache/htdocs
FCGI_ROLE = RESPONDER
GATEWAY_INTERFACE = CGI/1.1.
HTTP_ACCEPT = text/html, text/plain, application/applefile, application/
X-metamai
L-patch, sun-configured set-message, mail-file, default, postscript-file, aud
Io-file,
X-sun-attachment, text/enriched, text/richtext, application/andrew-ins
Et, x-be2
, Application/postscript, message/external-body, message/partial, appl
Ication/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.9 libwww-FM/2.14
PATH =/usr/local/bin:/usr/X11R6/bin:/usr/sbin:/opt/kde/bi
N:/home/m
Yhsu/bin:/usr/X11R6/bin:/usr/sbin:/opt/kde/bin:/usr/X11R6/bin:/usr/sbi
N:/opt/kd
E/bin
QUERY_STRING =
REMOTE_ADDR = 127.0.0.1
REMOTE_PORT = 1427
REQUEST_METHOD = GET
REQUEST_URI =/fcgi-bin/echo. fpl
SCRIPT_FILENAME =/usr/local/www/fcgi-bin/echo. fpl
SCRIPT_NAME =/fcgi-bin/echo. fpl
SERVER_ADMIN = myhsu@localhost.localdomain
SERVER_NAME = localhost. localdomain
SERVER_PORT = 80
SERVER_PROTOCOL = HTTP/1.0
SERVER_SIGNATURE =
Apache/1.3.6 Server at localhost. localdomain Port 80
SERVER_SOFTWARE = Apache/1.3.6 (Unix) mod_fastcgi/2.2.2
UNIQUE_ID = N1VIbX8AAAEAAAQnKKo
More on its way... wait a few seconds
Initial environment:
Finally, we will give you an example of fastcgi programming:
#! /Usr/local/bin/perl
Use CGI: Fast;
My $ counter = 0;
While (my $ cgi = new CGI: Fast ){
Print ("Content-type: text/html ");
Print ("We have served $ counter requests ");
$ Counter ++;
}
That's all,