Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the recommended way to use a non-system perl for a web app?

I want to run a Catalyst application on my web server, which has system perl v5.10. I want to use at least v5.12 for the app., and I don't want to meddle with the system perl.

Our sysadmin insists that the app. be run by a non-shell user (such as "nobody")

I know I can use perlbrew to use non-system perl for development, but I'm not sure what the best way to then run the live version is. How do people advise handling this situation?

like image 450
djh Avatar asked Aug 30 '12 15:08

djh


1 Answers

Since you're familiar with perlbrew, you could still use that to install Perl.

perlbrew install 5.16.1 --as=5.16.1t -Dusethreads

You just make sure you give proper permissions. Say your $PERLBREW_ROOT is /home/djh/perl5/perlbrew (the default):

chmod a+x /home/djh/
chmod a+x /home/djh/perl5/
chmod a+x /home/djh/perl5/perlbrew/
chmod a+x /home/djh/perl5/perlbrew/perls/
chmod -R a+rX /home/djh/perl5/perlbrew/perls/5.16.1t/  # Capital "X"!!!

Then use the following shebang line in your script:

#!/home/djh/perl5/perlbrew/perls/5.16.1t/bin/perl

But maybe you don't want it in your home. If so, this is what you can do:

cd /tmp
wget http://search.cpan.org/CPAN/authors/id/R/RJ/RJBS/perl-5.16.1.tar.bz2
tar xvjf perl-5.16.1.tar.bz2
cd perl-5.16.1
sh Configure -des -Dprefix=/opt/perls/5.16.1t -Dusethreads
make test

sudo mkdir /opt/perls/5.16.1t
sudo chown djh:djh /opt/perls/5.16.1t
make install

The installer will setup the permissions correctly. All you have to do is set the shebang to

#!/opt/perls/5.16.1t/bin/perl

("t" is my convention for threaded builds. Remove -Dusethreads if you don't want thread support.)

like image 137
ikegami Avatar answered Nov 09 '22 13:11

ikegami