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 )

In reply to RFC: Installing perl on CentOS/RedHat by gsiems

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.