Deploying Perl web applications

Subject tags: 

So this is a bit of a diversion from the whole theology thing, but… (This’ll probably confuse everyone on the CCBlogs site…)

In the missionary job, I’ve been setting up various web sites (including this one) and to make maintainence nice and easy, I’ve been using Drupal rather a lot. It’s a nice framework. One of the really nice things about it is that it’s very, very easy to install - untar the distribution into a directory on the web server, fill in some forms, and you have a new CMS. It really couldn’t be very much easier. If you get things wrong, it tells you what they are and how to fix it.

Coming back to Perl, I’ve been embarrassed at our web applications. Well, we have CPAN, which is a wonderful rich resource and people use CPAN modules liberally, as they should. But it does mean that deploying Perl web applications has required a lot of systems administration experience and often a lot of pain and aggravation.

So I’ve been working today on a Better Way, and I’m about 60% of the way there…

Last year I went to YAPC::Asia and heard Jesse talk about Shipwright. It makes bundling complex code distributions very simple. At the time I though, maybe we could use this to do one-click web application installs. But then I got busy and forgot about it.

Then a couple of days ago, he told me about his new tool, which you install by doing curl $url | perl. Nice and simple. Now the web application deployment idea was one whose time had come.

Here’s the end result. I’ve made a distribution of CGI::Wiki::Kwiki which you install like so:

cd /var/www/ # Or local equivalent
mkdir kwiki
cd kwiki
wget # This is the 5.10.x version
chmod +x install-kwiki.cgi

and then visit It’ll (hopefully) install all the dependencies, the templates, set up the wiki’s database, and then redirect you to the new web application. And when I say “all the dependencies”, I mean all these:

CGI::Wiki::Kwiki Getopt::Long CGI::Wiki::Search::DB CGI::Wiki DBD::SQLite Test::More Test::Harness File::Spec Scalar::Util
Carp Test File::Path Module::Build ExtUtils::Install Archive::Tar Compress::Zlib Compress::Raw::Bzip2 ExtUtils::MakeMaker
Compress::Raw::Zlib IO::Zlib Package::Constants ExtUtils::Manifest IO::File Data::Dumper Text::ParseWords File::Temp
ExtUtils::CBuilder DBI Storable DBD::Pg Text::WikiFormat URI::Escape MIME::Base64 Time::Piece HTML::PullParser
XSLoader HTML::Tagset DBIx::FullTextSearch Plucene IO::Scalar Lingua::Stem::En Lingua::PT::Stemmer Lingua::Stem::It
Lingua::Stem::Snowball::No Text::German Lingua::Stem::Snowball::Se Lingua::Stem::Fr Lingua::Stem::Snowball::Da
Lingua::Stem::Ru Memoize Bit::Vector::Minimal Class::Accessor base Encode Tie::Array::Sorted Class::Virtual
Carp::Assert Class::Data::Inheritable Class::ISA File::Slurp Digest::MD5 Digest::base DBD::mysql Template
AppConfig CGI Algorithm::Merge Algorithm::Diff CGI::Wiki::Plugin::Diff Module::Optional VCS::Lite CGI::Wiki::Formatter::UseMod
Test::MockObject Test::Exception Sub::Uplevel UNIVERSAL::isa UNIVERSAL::can URI::Find::Delimited

I think this is a step forward.

The really good part is that the first few steps of creating your own self-deploying Perl application is very easy:

  • Install Shipwright.
  • Create a repository:
    % shipwright create -r fs:kwiki-app/
  • Load all the code and all its dependencies into the repository (one command):
    % shipwright import -r fs:kwiki-app/ cpan:CGI::Wiki::Kwiki
  • Build it:
    % cd kwiki-app; ./bin/shipwright-build
  • Tar up the resulting distribution.

Unfortunately the next part, creating the install CGI, is currently done manually, but the next step is obviously to have that automated.