Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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
Re: Set up Catalyst with Fast CGI on Apache2
by Your Mother (Canon) 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/myapp_server.pl -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 XXXX_server.pl and also a script called XXXX_fastcgi.pl (where XXX is the name of your app). To deploy the app, you need to run that script like so:

    script/myapp_fastcgi.pl --listen /tmp/XXXX,sock -n 3 -p /tmp/XXXX.pid +-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/mod_fastcgi.so 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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://828630]
Approved by keszler
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2014-08-02 00:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (53 votes), past polls