djh
djh

Reputation: 83

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?

Upvotes: 5

Views: 755

Answers (2)

ikegami
ikegami

Reputation: 385809

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.)

Upvotes: 6

mob
mob

Reputation: 118605

Give nobody (i.e., everybody) read and execute permission to the perl executable(s) and all libraries (everything under the @INC directories).

Change the shebang line in all your applications scripts (including at least everything under your ./scripts directory) to the instance of perl that you want to use. Or if you want to be flexible about out, point the shebang line to a symbolic link that points to a desired perl executable. Make sure this link is also accessible to nobody.

Restart your application whenever you point your symbolic link to a different version of Perl.

Upvotes: 4

Related Questions