Using Cricket with mod_perl

mod_perl is an Apache module that allows you to run Perl scripts inside of Apache without forking a new process for each one. This saves lots of time, since Perl only needs to parse the script once and can execute it a number of times.

As of version 0.68, Cricket can run under mod_perl. Typically, no special code needs to be added to scripts to make them work in the mod_perl environment, but Cricket's lazy use of namespaces required some fix up work. Mea culpa. That work has been done now, and going forward, I intend to make sure Cricket works under mod_perl.

If you'd like to use Cricket under mod_perl, you need to first fetch and install Apache with the mod_perl module. Cricket has only been tested so far with Apache 1.3.6 and mod_perl 1.19. The best way to build and install Apache and mod_perl is to fetch both packages, uncompress and untar them into one directory, then go into the mod_perl directory first and follow the directions in the INSTALL.apaci file.

Once you have an installation of Apache with mod_perl installed, you need to add lines like the following to your httpd.conf file:

    <Files *.cgi>
      SetHandler perl-script
      PerlHandler Apache::Registry
      Options ExecCGI
    </Files>

These lines tell your webserver that whenever it sees a file ending in .cgi, it should let the embedded Perl interpreter run it. This, of course, is problematic if you have some .cgi files on your webserver that cannot be run by Perl. In that case, you should use a more restrictive specification than "*.cgi" to limit the scope of the directives to files in the Cricket user's home directory.

There seems to be a bug which causes Apache to fail to find a library file in some cases. Confusingly, this tends to happen when it's trying to handle a URL that points to an image, resulting in missing images. This is strange, since serving up images should not require the Perl interpreter. You can fix this by setting the PERL5LIB environment variable to the Cricket library directory before starting the Apache webserver.

If you are going to be editing the library files (i.e. to add a new feature), you'll want to definitely add the "PerlInitHandler Apache::StatINC" directive to your config file. This will make mod_perl check library timestamps and reload/reparse them when necessary. You should not run a production server with this enabled, since it does some extra work each time a library is used, which could be avoided. If you are not using the StatINC module, you will need to restart your server anytime you change a library file, or else the changes will not be picked up.

Cricket version 1.0.5, released 2004-03-28.

Copyright (C) 1998-2000 Jeff Allen. Cricket is released under the GNU General Public License.