Installing a custom version of Perl locally

Overview

This article walks you through installing a custom version of Perl locally under your username. If your server is currently running Ubuntu 18 (Bionic), the Perl version is 5.26. This article shows how to install an older version if your site requires it.

It's highly recommended that you only use a version of Perl which is currently maintained. This means you should not use a version that has been End-of-Life'd. You can view a full list of versions and their status here:

Installing

  1. Log into your server via SSH.
  2. Visit https://www.cpan.org/src/ to download your version of Perl. Run the wget command to download the tar.gz file.
    [server]$ wget https://www.cpan.org/src/5.0/perl-5.18.4.tar.gz
  3. Decompress this file.
    [server]$ tar zxf perl-5.18.4.tar.gz
  4. Change into the new directory.
    [server]$ cd perl-5.18.4
  5. Run the configure command for the directory you wish to install into. This example installs into a directory named /opt/perl under your username.
    [server]$ ./Configure -des -Dprefix=$HOME/opt/perl
  6. Next, run make, make test, and finally make install
    [server]$ make
    [server]$ make test
    [server]$ make install
  7. Add code to your .bash_profile to find the local version.
    export PATH=$HOME/opt/perl/bin:$PATH
  8. Source the .bash_profile.
    [server]$ . ~/.bash_profile
  9. Finally, check to confirm the new version is being used.
    [server]$ perl -v
    This is perl 5, version 18, subversion 4 (v5.18.4) built for x86_64-linux

Did this article answer your questions?

Article last updated PST.