Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

RFC: Installing perl on CentOS/RedHat

by gsiems (Chaplain)
on Oct 06, 2009 at 03:27 UTC ( #799376=perlmeditation: print w/ replies, xml ) Need Help??

A while ago I decided to investigate some of the newer goodies available in perl. Specifically, I wanted to look at Catalyst and Padre. In that I work with RedHat/CentOS at $job I wanted things to run on RedHat/CentOS (version 5 to be exact).

Historically I've stuck with using rpms to install maintain all the packages on my boxes. For those packages that either come with the distribution or are available through EPEL this works well. For packages that:

    a) are not available through the distribution or EPEL, and
    b) have few dependencies not covered by a) then cpanspec fills in the gap nicely.

This approach doesn't work when trying to install something like Catalyst so I decided that it was time to install a newer local installation of perl.

While I've read multiple times recommending installation of a separate perl than the system supplied one I have yet to read where anyone layed out how they went about it.

My requirements were that:

    a) the local install could not be owned by root as I did not want to risk messing up the perl install that came with the system,
    b) the install could not be under /home as it would likely be used by more than one user, and
    c) any scripts written have to work under the default bash shell.
So, my approach was/is as follows. Hopefully it is of use to someone. Comments are (probably) most welcome.

1. Logon as the non-root owner of the installation

2. Create the installation directory

Since one of my requirements is to not install under /home, and as the other oddball installs are already under /opt, I decided to install under /opt (rather than /usr/local).

TEMP_FILE=`mktemp -p $HOME` cat <<EOT> $TEMP_FILE /bin/mkdir -p /opt/perl/ /bin/chown $USER.$USER /opt/perl EOT su -c "sh $TEMP_FILE" rm $TEMP_FILE

3. Create an environment script for the local install

cat <<'EOT'> /opt/perl/perl_profile.sh #!/bin/sh PERL_VER=5.10.1 export PERL_VER PERL_BASE=/opt/perl export PERL_BASE PERL_HOME=$PERL_BASE/current export PERL_HOME # ensure that the local perl is at the front of the path, but don't # add it again if it is already there. ( echo $PATH | grep "^$PERL_HOME" > /dev/null ) || PATH=$PERL_HOME/bin +:$PATH export PATH EOT chmod 755 /opt/perl/perl_profile.sh

4. Perform the local install

Note that in order to get threads working (needed for Padre) I resorted to lifting the compile arguments from the perl source rpm and adjusted to my needs/liking.

Also note that, since this installation is not done as root, it can not (to my knowlege) support setuid.

. /opt/perl/perl_profile.sh mkdir $PERL_HOME mkdir $PERL_BASE/install cd $PERL_BASE/install wget http://search.cpan.org/CPAN/authors/id/D/DA/DAPM/perl-${PERL_VER} +.tar.gz tar -xzf perl-${PERL_VER}.tar.gz ( cd perl-${PERL_VER} # NOTES: # - Configure parameters shamelessly derived from the vendor per +l.spec # file and the output of `perl -V` # - suid is disabled as we are not installing as root UNAME_I=`uname -i` UNAME_S=`uname -s | tr [A-Z] [a-z]` sh Configure -des \ -Doptimize="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 \ -fexceptions -fstack-protector --param=ssp-buffer-size=4 \ -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tabl +es" \ -Dversion=${PERL_VER} \ -Dmyhostname=localhost \ -Dperladmin=root@localhost \ -Dcc=gcc \ -Dinstallprefix=${PERL_HOME} \ -Dprefix=${PERL_HOME} \ -Darchname=${UNAME_I}-${UNAME_S} \ -Dvendorprefix=${PERL_HOME} \ -Dsiteprefix=${PERL_HOME} \ -Duseshrplib \ -Dusethreads \ -Duseithreads \ -Duselargefiles \ -Ud_dosuid \ -Dd_semctl_semun \ -Di_db \ -Ui_ndbm \ -Di_gdbm \ -Di_shadow \ -Di_syslog \ -Dman3ext=3pm \ -Duseperlio \ -Dinstallusrbinperl=n \ -Ubincompat5005 \ -Uversiononly \ -Dpager='/usr/bin/less -isr' \ -D/opt/perld_gethostent_r_proto -Ud_endhostent_r_proto \ -Ud_sethostent_r_proto \ -Ud_endprotoent_r_proto -Ud_setprotoent_r_proto \ -Ud_endservent_r_proto -Ud_setservent_r_proto \ -Dinc_version_list=${PERL_VER} \ -Dscriptdir=${PERL_HOME}/bin make && make test && make install )

Comment on RFC: Installing perl on CentOS/RedHat
Select or Download Code
Re: RFC: Installing perl on CentOS/RedHat
by proceng (Scribe) on Oct 07, 2009 at 04:02 UTC
    You might also look at cpan2rpm (http://sourceforge.net/projects/cpan2rpm/). I thought it was also available from one of the RH sources, but I don't see it (recently upgraded my systems).

      Cpan2rpm is available as part of the distro and is just a 'yum install cpan2rpm' away. Actually, if you are using EPEL, then cpanspec is just a 'yum install cpanspec' away also.

      IIRC, I found out about cpanspec from a Dave Cross presentation (http://www.slideshare.net/davorg/perl-in-rpmland-presentation) and have come to prefer it over cpan2rpm.

      --gsiems

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://799376]
Approved by McDarren
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2014-07-12 20:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (241 votes), past polls