ModPerlEngineContrib

Permits Foswiki to be executed under mod_perl

Overview

This is a runtime engine component from Foswiki Standalone architecture.

mod_perl is the Perl API to the Apache web server. It permits hooking applications into Apache, providing good performance and great flexibility.

It has better performance than CGI because it loads and compiles apps at Apache initialization and apps are kept in memory as long as Apache itself, so there is no need to fork+load+compile all the code for each request.

Installation Instructions

Install ModPerlEngineContrib either manually (download the package and extract its contents over your foswiki directory) or using configure (under Extensions section, push the Find More Extensions button).

Visit the apache config generator and fill in the fields according to your environment. Select mod_perl as your Runtime Engine and choose your apache version. Push the Update config file button and you'll get your config file.

ALERT! When installed for the first time, Foswiki must be configured. Run configure before enabling this contrib or else Apache will not start, reporting an error about a missing lib/LocalSite.cfg

In the web server configuration, you will need to load mod_perl but it is also recommended to load the Apache HTTP Request Library (module apreq). If apreq is not loaded, the following error may be encountered in certain situations, e.g., during login:
apache2: symbol lookup error: /usr/lib/perl5/auto/APR/Request/Apache2/Apache2.so: undefined symbol: apreq_handle_apache2

Confirming mod_perl installation

You may (though not necessarily) be able to confirm that mod_perl is installed and enabled by checking in configure's "Environment Variables" section. a sample:

SERVER_SIGNATURE Apache/2.2.9 (Debian) mod_apreq2-20051231/2.6.0 mod_perl/2.0.4 Perl/v5.10.0 Server at 127.0.0.1 Port 2116
SERVER_SOFTWARE Apache/2.2.9 (Debian) mod_apreq2-20051231/2.6.0 mod_perl/2.0.4 Perl/v5.10.0

Another technique to see which modules are enabled is using apache2ctl
$ apache2ctl -M | grep perl_module
 perl_module (shared)
If not found, enable mod_perl with
$ a2enmod mod_perl

Foswiki configuration tuning

Forking new processes under mod_perl can be very slow, so some configuration changes are recommended.

Access the configure script and click the Yes, I've read all the documentation button to show the expert settings. Go to Store Settings:

=mod_perl+ configuration tuning

mod_perl limits the size of attachments to 64M by default. Set the APREQ2_ReadLimit to the maximum expected upload to permit larger attachments.

Note that this should be kept in sync with the Foswiki ATTACHFILESIZELIMIT, set in SitePreferences, default taken from SitePreferences.
<IfModule mod_perl.c>
   PerlSwitches -wT
   # mod_perl_startup.pl must exist, otherwise Apache will not start.
   PerlRequire "/var/www/foswiki/tools/mod_perl_startup.pl"
   APREQ2_ReadLimit  104857600
</IfModule>

Known Issues

  • Apache must be =restart=ed in order for configuration changes take effect.
  • The bin/configure script is an exception and should be run as a plain CGI script. The required SetHandler cgi-script should already be specified in the in your Apache config or bin/.htaccess file.
   <FilesMatch "configure.*">
      SetHandler cgi-script
      .
      .
   </FilesMatch>
  • If you are using some extension that add files to the bin/ directory, you may face problems as they were not designed to be executed under mod_perl. You should configure them to be run as plain CGI scripts. You can replace Files directive by FilesMatch and list all the exceptions.

List of Files

File Description
data/System/ModPerlEngineContrib.txt Documentation
lib/Foswiki/Contrib/ModPerlEngineContrib/DEPENDENCIES  
lib/Foswiki/Contrib/ModPerlEngineContrib.pm Perl module
lib/Foswiki/Engine/Apache.pm Perl module
lib/Foswiki/Engine/Apache/MP13.pm Perl module
lib/Foswiki/Engine/Apache2.pm Perl module
lib/Foswiki/Engine/Apache2/MP20.pm Perl module
tools/mod_perl_startup.pl Perl script

Info

Change History:  
20 Oct 2015 (1.01) Released with Foswiki 2.0.3.
Foswikitask:Item13830: Unable to upload utf-8 filenames as attachments.
14 Jun 2015 (1.00) Released with Foswiki 2.0.
Foswikitask:Item13378: Foswikitask:Item13405: Update for UNICODE core
Foswikitask:Item13228: Fix JSON operation with ApacheRequest2
Foswikitask:Item13125: CGI updates
Foswikitask:Item13225: Fix compatibility with Apache 2.4
Foswikitask:Item13052: Documentation improvements for APREQ2_ReadLimit
Foswikitask:Item9139: Improve compatibility.
03 Sep 2009 (0.9.2) Improved documentation regarding module apreq
12 Apr 2009 (0.9.1) Improved documentation
12 Jan 2009 (0.9.0) Initial Release
Dependencies:
NameVersionDescription
mod_perl>=1.24Required if you're using Apache 1.3 and plan to enable mod_perl
mod_perl2>=2.0Required if you're using Apache 2.x and plan to enable mod_perl
Apache::Request>=1.30Optional. Recommended if you're using Apache 1.3 and plan to enable mod_perl
Apache2::Request>=2.0Optional. Recommended if you're using Apache 2.x and plan to enable mod_perl

Topic revision: r1 - 16 Nov 2015, UnknownUser
This site is powered by FoswikiCopyright © by the contributing authors. All material on this site is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback