mod_perl

This page is a work in progress. It describes step by step what to do to run koha under mod_perl.

Software Requirements

Install the mod_perl package from your Linux distribution.

Debian/Ubuntu

# aptitude install libapache2-mod-perl2

Mandriva

# urpmi apache-mod_perl

OpenSuse

# zypper install apache2-mod_perl

Virtual Hosts

The optimal solution, in terms of performance, should be to use ModPerl::Registry as response handler. A lot of work is needed to be done in order to run Koha in this configuration. This changes are expected for Koha v3.4. Koha SHOULD be run safely in with mod_perl until that, using ModPerl::PerlRunPrefork.

Solution 1: Per-VirtualHost configuration

Modify your virtual host to explain how handling perl scripts.

#intranet
Listen 8079
<VirtualHost localhost:8079>
   ServerAdmin antoine@koha-fr.org
   DocumentRoot /koha/rel_3_0
   ScriptAlias /cgi-bin/koha "/koha/rel_3_0"
   ServerName localhost
   ErrorLog "/var/log/apache2/rel_3_0-error.log"
   Redirect permanent index.html http://localhost:8079/cgi-bin/koha/mainpage.pl
   SetEnv PERL5LIB "/koha/rel_3_0"
   SetEnv KOHA_CONF "/koha/conf/rel_3_0.xml"
</VirtualHost>

by this

#intranet
Listen 8079
<VirtualHost localhost:8079>
   ServerAdmin antoine@koha-fr.org
   DocumentRoot /koha/rel_3_0
   ScriptAlias /cgi-bin/koha "/koha/rel_3_0"
   ServerName localhost
   ErrorLog "/var/log/apache2/rel_3_0-error.log"
   Redirect permanent index.html http://localhost:8079/cgi-bin/koha/mainpage.pl
   SetEnv KOHA_CONF "/koha/conf/rel_3_0.xml"
   # mod_perl :
   SetHandler perl-script
   PerlResponseHandler ModPerl::PerlRunPrefork
   PerlOptions +ParseHeaders
   Options +ExecCGI
</VirtualHost>

Solution 2: Global configuration

It is better, imho, because it just explain that ALL .pl (in every VirtualHost) are for mod_perl. And nothing more. Under my Mandriva, I (Paul) had some problems with mod_perl trying to compile & execute css, that are, with cvs Koha, in a subdirectory of the main intranet scripts. Add in apache config file :

<Files *.pl>
SetHandler perl-script
   PerlResponseHandler ModPerl::PerlRunPrefork
    PerlOptions +ParseHeaders
PerlSendHeader On
Options +ExecCGI
</Files>

Define PERL5LIB

  • remove from your VirtualHost the SetEnv PERL5LIB=/path/to/koha
  • create a file /path/to/startup.pl (if it isn't already exist) and write on it some perl specifications like :
#!/usr/bin/perl
 
use strict;
use warnings;
use lib qw(/koha/rel_3_0);  # this line fixe PERL5LIB !
 
# you can add here what you want.
# see perl.apache.org for more details.
 
1;                          # don't forget to add it.
  • modify your apache2 configuration file to add this line :
PerlRequire /path/to/startup.pl

And that should be ok !

Note

To know if the you are running your perl script under mod_perl, there is a special environnement variable

 
$ENV{MOD_PERL} or die "Execution without mod_perl !";

WARNING / DISCLAIMER

When running mod_perl on a developer computer you will face problems : when you modify a .pm, it seems that mod_perl misses the change, and still uses the pre-compiled version of the .pl that uses the modified .pm. Thus, the modifs are not visible.

The best solution (unless there is a way to change this behaviour) is to remove mod_perl for developers

 
mod_perl.txt · Last modified: 2010/02/18 23:09 by magnusenger
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki