[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Apache2 with Plack;

Hi all,

After I got my new LSMB environment (1.4.27 / AMD-450) up and running
I was a bit surprised to find it performing about the same as my old
LSMB environment (1.2.26 / AMD Duron 800MHz).
Ok, the AMD-450 (2x 1.65GHz) isn't a beast, but 10 secs to list
the Belgium COA on the screen is a long time!

So I gave starman a try, using the instructions in the INSTALL.
The Belgium COA now took 7 secs to complete due to better Perl

On the other hand most of us are familiar with Apache.
Apache can serve both static and dynamic content, offers virtual
hosting, etc. Wouldn't it be nice if we could use LSMB on Apache
in a faster configuration than good old slow CGI?

I looked at the Dancer deployment page and learned that you can
run Dancer from Apache with Plack via mod_perl.
I installed mod_perl from Debian Jessie.
Using https://metacpan.org/pod/Plack::Handler::Apache2 I modified
the ledgersmb-httpd-2.4.conf and created a startup.pl to preload
the application.

After some troubleshooting I managed to get Apache running and
the application preloading without any errors in the Apache
error.log file.
However when I try to login the application fails:

2016/05/16 17:22:14 - ERROR - LedgerSMB::_error /opt/ledgersmb/1.4.27/LedgerSMB.pm (639) -- Not a HASH reference at /opt/ledgersmb/1.4.27/LedgerSMB/Template/HTML.pm line 90.

What's going wrong here?
Looks if something isn't properly initialized.


--- ledgersmb-httpd-2.4.conf	2016-04-13 21:52:43.921864793 +0200
+++ ledgersmb-httpd-2.4-plack.conf	2016-05-16 18:53:52.286954666 +0200
@@ -2,6 +2,17 @@
 Alias /ledgersmb /opt/ledgersmb/1.4.27/
+# W20160516
+# mod_perl Plack config
+<Location /ledgersmb>
+SetHandler perl-script
+PerlResponseHandler Plack::Handler::Apache2
+PerlSetVar psgi_app /opt/ledgersmb/1.4.27/tools/starman.psgi
+PerlPostConfigRequire /opt/ledgersmb/1.4.27/startup.pl
 <Directory /opt/ledgersmb/1.4.27>
   # Rewrite rule to allow HTTP Authorization information to the scripts only
@@ -18,9 +29,9 @@
   RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
-  Options +ExecCGI 
-  AllowOverride All
-  AddHandler cgi-script .pl

#!/usr/bin/env perl

# W20160516
# Startup file for Apache2 with Plack
# Doc:
# https://metacpan.org/pod/Plack::Handler::Apache2

use strict;
use warnings;
use Apache2::ServerUtil ();

    return unless Apache2::ServerUtil::restart_count() > 1;

    require lib;

    require Plack::Handler::Apache2;

    # Facilitate opening the "ledgersmb.conf"
    chdir '/opt/ledgersmb/1.4.27/';

    my @psgis = ('/opt/ledgersmb/1.4.27/tools/starman.psgi');
    foreach my $psgi (@psgis) {

# Must return true

Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
Ledger-smb-users mailing list