Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Set up Catalyst with Fast CGI on Apache2

by CColin (Scribe)
on Mar 15, 2010 at 02:37 UTC ( #828630=perlquestion: print w/replies, xml ) Need Help??
CColin has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,
I've been struggling all day to try and set up FastCGI on a LAN server running Apache2 in order to run some Perl scripts that use FAst CGI as a POC, so I can merrily go off and start trying to develop an app.
I can't find any Hello world example that applies to both the perl script and the set up of FastCGI and Apache. Yes there are perl scripts, but no there is nothing that seems to relate to the whole shebang (pun intended).
My server is running Hardy Heron, and I've installed apache2 with the libapache2-mod-fastcgi. After hours downloading half of CPAN and other dependencies I also seem to have installed Catalyst.
In fact, I have to say the marketing promise of the elegant framework that is Catalyst (which I desperately want to believe) is a ways short of setting the thing up.
I also have the "Definitive Guide to Catalyst". Not useful IMHO, especially as it recommends using Fast CGI on Apache but then hangs you out to dry to set the thing up (this is the only reason I'm trying to set it up actually). True, I have little prior experience with Apache, but should I have to have had?
I've seen the Catalyst website, too, but that is opaque (at best) for someone who hasn't done all this before.
Any guidance towards a Hello World example for this environment, eg. exactly what has to be set up in the conf files, and a hello world script for this environment would be appreciated. I've tried some of the disparate config settings on line but none seem to work.
  • Comment on Set up Catalyst with Fast CGI on Apache2

Replies are listed 'Best First'.
Re: Set up Catalyst with Fast CGI on Apache2
by Your Mother (Chancellor) on Mar 15, 2010 at 04:26 UTC

    Congrats! You chose wisely. Welllll.... luckily? Catalyst has a ramp up to get into it but it definitely repays later with ease of extension and scale. Here is probably the tack you want-

    Instructions in Catalyst::Engine::FastCGI -- see specifically the "standalone server mode," it has two main advantages: 1) apache problems don't affect it, 2) zero downtime production changes. This goes well with it for *nix: Catalyst::Helper::FastCGI::ExternalServer. In the event you use that to make your app into a service, you'll probably want to also use Catalyst::Log::Log4perl.

    Further digging if there is a specific that you get stuck on or something is unclear; Google: deploy catalyst fcgi and variations on that theme. The mailing list and irc are generally quite helpful.

    Update: I should add that using fastcgi or modperl for development is a bad idea. You have to restart to see changes. You should be using the plain server -- scripts/ -d -r -- in restart and debug modes to do dev work. It is wonderful to work this way. If you are doing your bit sanely there will be little or even no difference between the dev server and production deployment. Don't get hung up on a production style, bomb-proof deployment to get started or experiment. Have fun!

Re: Set up Catalyst with Fast CGI on Apache2
by tospo (Hermit) on Apr 14, 2010 at 18:01 UTC

    I'm also currently in the process of getting my first Catalyst App into live mode and, yes, it does take some getting used to and I understand your problems very well.

    Essentially, it boils down to this: your Catalyst app comes with a script directory. In there you find the standalone server script for development and also a script called (where XXX is the name of your app). To deploy the app, you need to run that script like so:

    script/ --listen /tmp/XXXX,sock -n 3 -p /tmp/ +-d

    This tells the server to start three processes that listen to a socket file /tmp/XXXX,sock (that's used for apache to connect to your app later) and write their process id file in /tmp as well. The -d option makes the script go to the background and run as a daemon.

    Now you need to connect apache to your fastcgi app. You have installed mod_fastcgi already. in your apache config file, add this:

    LoadModule fastcgi_module modules/ FastCGIExternalServer /tmp/XXXX.fcgi -socket /tmp/XXXX.sock Alias /XXXX/ /tmp/XXXX.fcgi/

    This bit is slightly esoteric :-) As far as I understand, /tmp/XXXX.fcgi ist not an actual file, but it needs to be in a directory that is writable to apache and it must have the .fcgi suffix for some reason. Just go with the flow here... You then actually hook up you app by pointing apache to the socket file that your fastcgi server created. This worked for me. Good luck!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://828630]
Approved by keszler
and the monks are mute...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (10)
As of 2017-06-26 14:48 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (582 votes). Check out past polls.