Simplifying the Deployment of Catalyst Perl Applications in Shared Hosting

| No Comments | No TrackBacks

Deploying Perl in shared hosting environments used to be an unpleasant experience, since most hosting providers would refuse to install and keep up-to-date CPAN modules. Fortunally this is no longer the case, since the advent of local::lib, which allows the build and installing of modules in a private directory. But this still required the user to have shell access to the machine, in order to bootstrap the local::lib and install all the dependencies.

The most problematic is not just requiring shell access, but actually requiring the compiler toolkit as well as the development headers for libraries such as libpq-dev (for the DBD::Pg module) or libxml2-dev (for the XML::LibXML module). This would certainly be a problem for a lot of hosting providers.

The last time I started building a local::lib bootstrap I came to the following realization. The machine I'm using is a Debian Lenny, the machine in the hosting provider is a Debian Lenny, so all I need to do is bootstrap the local::lib in my own machine (actually doing it inside a fresh debootstrapped chroot, to actually installing every non-core module by cpan). Then I just created a tarball with it and sent to the server and voilĂ , it just worked.

Of course my chroot required all the development headers as well as the compiler toolchain, but when I move the local::lib dir to the server, everything is already compiled, so I just need to make sure the postgresql client library is installed (which was already the case) as well as the libxml2 package (which was also the case).

So I realized this image can be re-used in any hosting provider using Debian-Lenny- i386. As I wouldn't like to have my blog shutdown due to excess traffic, I've uploaded the file to rapidshare, feel free to take it to a more convenient place (please tell me the link so I can add it here) -- I have removed the manpages in order to reduce the file size (reduced about 50%). UPDATE: arcanez has kindly provided two other mirrors, and arw__ provided a third for that file so you don't need to suffer from rapidshare.

How to use it?

Simply unpack it into your user's account, it will create a "perl5" directory, if your hosting provider doesn't allow shell access, simply unpack it anywhere into your local machine and use the ftp client to send all the files (remember to set binary mode, since there will be binary files in there).

Then you need to include that path into your Perl's include directory, you can:

  • set the PERL5LIB environment directory with /home/youruser/perl5/lib/perl5:/home/youruser/perl5/lib/perl5/i486-linux-gnu-thread-multi

  • add -I/home/youruser/perl5/lib/perl5 -I/home/youruser/perl5/lib/perl5/i486-linux-gnu-thread-multi in the #!/usr/bin/perl line

  • use lib '/home/youruser/perl5/lib/perl5'; use lib '/home/youruser/perl5/lib/perl5/i486-linux-gnu-thread-multi'; # into your fastcgi script

If more people think this is a good idea, we might eventually start having different prebuilt images, since that is completely OS-Version specific. The image I built is intended for use ONLY on Debian Lenny i386 machines, it will fail and segfault miserably if you try to use it in other OS and/or version.

No TrackBacks

TrackBack URL:

Leave a comment

About this Entry

This page contains a single entry by Daniel Ruoso published on April 24, 2010 11:46 AM.

Writing Games in Perl - Part 6 - Math for dummies was the previous entry in this blog.

Writing Games in Perl - Part 7 - Game Map is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.