fcgi / fastcgi tests

Here are some test fcgi / fastcgi perl scripts.

The Apache modules mod_fcgi and mod_fastcgi are similar, but mod_fcgi is the free license variant of mod_fastcgi (as in free code not free money) and there are technical differences between them. See What’s the difference between “mod_fastcgi” and “mod_fcgid”? for more info.

Basic hello world using FCGI:

# Hello World Script
# Filename: hello.cgi, or hello.fcgi
use FCGI;

while ( FCGI::accept >= 0 ) {
  print "Content-type: text/html\n\n";
  print "Hello world.";

Script showing more info:


use FCGI;

$cnt = 0;

while (FCGI::accept() >= 0)
   print ("Content-type: text/html\r\n\r\n");
   print ("<head>\n<title>FastCGI Demo Page (perl)</title>\n</head>\n");
   print  ("<h1>FastCGI Demo Page (perl)</h1>\n");
   print ("This is coming from a FastCGI server.\n<BR>\n");
   print ("Running on <EM>$ENV{USER}</EM> to <EM>$ENV{REMOTE_HOST}</EM>\n<BR>\n");
   print ("This is connection number $cnt\n");

Test of CGI:Fast, which is the CGI interface to FastCGI.


use strict;
use CGI::Fast;

my $count = 0;
while (my $q = CGI::Fast->new) {
    print("Content-Type: text/plain\n\n");
    print("Process ID: $$; Count is: " . ++$count);

Last modified: 11/01/2010 Tags: , ,

Related Pages

Other pages possibly of interest:

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top