Perl & mod_fcgid- how can I make sure it's running & being taken advantage of?
October 14, 2008 1:13 PM   Subscribe

I have a couple Perl scripts I'm publishing soon, and I want to make sure they'll run under mod_fcgid in order to keep the server load as low as possible. Previously, I've only ever run scripts that test FastCGI (ie, while ( my $q = new CGI::Fast ) { $count++; echo $count;}) or taken advantage of larger Perl packages (like MovableType) that claim to run as FCGI as long as you set up Apache & FastCGI/mod_fcgid properly and change the file suffix to ".fcgi". So, here's my question: do I need to do anything besides change the file suffix of my scripts, and if so, what?
posted by paul_smatatoes to Computers & Internet (2 answers total) 1 user marked this as a favorite
You will at least need to configure apache to run .fcgi files as mod_fcgid scripts. Here's the configuration we use to run Movable Type on our servers (from /etc/httpd/conf.d/fcgid.conf):

LoadModule fcgid_module modules/
# Use FastCGI to process .fcg .fcgi & .fpl scripts
# Don't do this if mod_fastcgi is present, as it will try to do the same thing

AddHandler fcgid-script fcg fcgi fpl

# Sane place to put sockets
SocketPath run/mod_fcgid

IdleTimeout 3600
ProcessLifeTime 7200
MaxProcessCount 50
DefaultMinClassProcessCount -1
DefaultMaxClassProcessCount 5
IPCConnectTimeout 8
IPCCommTimeout 600

A script that is running properly as a fastcgi script will remain persistant in memory and will be included in the output from `ps -fax`:

15883 ? S 0:00 \_ /usr/sbin/httpd -k start
15925 ? S 0:07 | \_ /usr/bin/perl -w /path/to/your/script.fcgi

posted by quinncom at 5:01 PM on October 14, 2008

You'll want to be careful of that class of bugs which tend to expose themselves under persistence. For example, the thing where a hash has a single iterator that gets bumped every time you use each...
posted by brennen at 1:19 PM on October 30, 2008

« Older So WHAT is wrong with socialism again?   |   Should I stay or should I go? (Education remix) Newer »
This thread is closed to new comments.