PDA

View Full Version : fastCGI and mod_perl install steps



PhonemeAnalysis
12-23-2007, 10:44 PM
hello wizards -

i wanted to post what i went thru to get both fastCGI and mod_perl working.

being seriously 'technically challenged', it took me quite a bit longer than it will take most normal people.

according to this chart:
http://dmst.aueb.gr/dds/pubs/conf/2002-SANE-DynCont/html/throughput.gif
http://dmst.aueb.gr/dds/pubs/conf/2002-SANE-DynCont/html/dyncont.html

it appears that fastCGI is better, but i have no opinion (yet)

below are the steps i went thru to get both working. good luck!


========= f a s t C G I ==============================
# http://www.fastcgi.com/devkit/doc/fastcgi-prog-guide/ch3perl.htm

#this little program worked out of the box, once i installed fastCGI on the westhost Site Applications manager


#! /usr/bin/perl

use FCGI; # Imports the library; required line

# Initialization code

$cnt = 0;

# Response loop

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{SERVER_NAME}</EM> to <EM>$ENV{REMOTE_HOST}</EM>\n<BR>\n";
$cnt++;
print "This is connection number $cnt\n";
}


========== m o d p e r l ==============================
http://www.perl.com/pub/a/2002/03/22/modperl.html?page=2

## 1) go to your home directory
cd ~ ;

## 2) create a testModPerlDirectory
mkdir testModPerlDirectory;

## 3) set the testModPerlDirectory to world read/execute
chmod 755 testModPerlDirectory;

## 4) go into that directory
cd testModPerlDirectory;

## 5) create the myTestProgram.pl program
cat > myTestProgram.pl;
#!/usr/bin/perl
print "Content-type: text/plain\n\n";
print "mod_perl rules!\n";

perl -c myTestProgram.pl; ## 06) make sure the program works!


## 07) add the following lines to the bottom of your mod-perl.conf file:
cat >> /etc/httpd/conf.d/mod_perl.conf;
Alias /perl/ /home/yourHomeDirectoryName/testModPerlDirectory/
PerlModule ModPerl::Registry
<Location /perl/>
SetHandler perl-script
PerlHandler ModPerl::Registry
Options +ExecCGI
PerlSendHeader On
allow from all
</Location>

## 08) stop the apache server
apachectl stop ;

## 09) (re)start the apache server
apachectl start ;

## 10) make sure your apache restarted!
ps -ef | grep httpd ;

## look for /usr/sbin/httpd -k start a couple times

now, in your favorite browser: http://yourHostName/perl/myTestProgram.pl