What is the recommended way to use non-system perl for a web application?

I want to run a Catalyst application on my web server with system perl v5.10. I want to use at least v5.12 for the application, and I do not want to interfere with the perl system.

Our system administrator insists that the application. run by the user without a shell (for example, "nobody")

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

+6
source share
2 answers

Since you are familiar with perlbrew, you can still use this to install Perl.

perlbrew install 5.16.1 --as=5.16.1t -Dusethreads 

Just make sure you give the appropriate permissions. Let's say $PERLBREW_ROOT /home/djh/perl5/perlbrew (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 the script:

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

But perhaps you do not want this 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 configure permissions correctly. All you have to do is install shebang on

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

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

+6
source

Let nobody (i.e. everyone) read and execute permissions for the perl executables and all libraries (all in the @INC directories).

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

Reboot the application when you point your symbolic link to another version of Perl.

+4
source

Source: https://habr.com/ru/post/924182/


All Articles