MojoMojo Running via External FastCGI
MojoMojo is avant-garde wiki software that uses the Catalyst Framework and a buttload of CPAN modules. External FastCGI is useful for separating the application processes from the web server. MojoMojo, being a Catalyst application, gives you a FastCGI enabled application for free. Once you've gotten MojoMojo installed, it's easy as pie to configure apache to use external FastCGI instances of MojoMojo. Read on to find out how.
FastCGI is an CGI done right. It is designed to improve peformance and scalability of CGI. A distinct advantage of running FastCGI instances in their own process space is the separation of application processes from the web server. Thus application restarts don't require web server restarts which is real handy for times when the site is busy but the application must be restarted.
- Perl Modules: FCGI and FCGI::ProcManager
- Apache module: mod_fastcgi - installed from debian package: libapache2-mod-fastcgi
- Enable the module with fastcgi.load and fastcgi.conf - start with nothing in fastcgi.conf
- fastcgi.conf has handler directive: AddHandler fastcgi-script .fcgi - this is not needed for this example
- add to a conf file: Use FastCGI in separate process on distinct host (local or remote)
FastCgiExternalServer /var/www/virtual-file.fcgi -host remote.host.org:3001 Alias /cia-wiki/ /var/www/virtual-file.fcgi/
The directories must exist but the filename is arbitary1.
- Start the fastcgi processes:
mojomojo_fastcgi.pl -l :3001 -n 3 -p /home/hunter/mojo_fastcgi.pid -d
This starts 3 fastcgi instances on port 3001, puts a process id in the mojo_fastcgi.pid file and puts fastcgi in daemon mode.
- Kill fastcgi processes: kill -TERM first process. Use -p option when starting to specify pid file.
Make an init script
I have not tested it yet, but it appears an init script for starting FastCGI Catalyst app. can be created using Catalyst::Helper::FastCGI::ExternalServer. Another possibility for managing FastCGI processes is FCGI::Engine::Manager
A much more in-depth article about using external FastCGI server with Catalyst applications is available at "zzo's perl journal":http://use.perl.org/~zzo/journal/34146
The absolute path must exist and be readable by the fastcgi process, but the filename at the end is virtual (just used for mapping of fastcgi process to the URI) so it can be anything. ↩
Showing changes from previous revision.