转载用于记录:如侵权请联系我删除
一、需要下载tar包,因此我用的(二)perlbrew 方式安装 perl
1.1 perl 源码安装(忽略,该方式本人未成功,请参考后面的(二)perlbrew 方式安装 perl)
安装 perl 之前需要先安装 make, gcc
代码如下:
yum install gcc make
然后开始安装:
代码如下:
wget http://www.cpan.org/src/5.0/perl-5.20.1.tar.gz
tar -xzf perl-5.20.1.tar.gz
cd perl-5.20.1
./Configure -des -Dprefix=$HOME/localperl
make
make test
make install
二、perlbrew 方式安装 perl
2.1 perlbrew 安装
代码如下:
[root@ithomer ~]# yum install perlbrew
[root@ithomer ~]# perlbrew version
/usr/bin/perlbrew– App::perlbrew/0.28
2.1.1 如果上面安装失败,可使用 cpan 安装 perlbrew,如果上面成功(可忽略)
代码如下:
sudo yum install cpan
sudo cpan App::perlbrew
perlbrew init
perlbrew version
2.2 perlbrew 初始化
代码如下:
[root@ithomer ~]# perlbrew init
Perlbrew environment initiated, required directories are created under/p
~/perl5/perlbrew
Paste the following line(s) to the end of your ~/.bashrc and start a
new shell, perlbrew should be up and fully functional from there:
source ~/perl5/perlbrew/etc/bashrc
For further instructions, simply run perlbrew to see the help message.
Enjoy perlbrew at $HOME!!
重点
根据上面提示,复制 source ~/perl5/perlbrew/etc/bashrc 粘贴到 ~/.bashrc 文件最后一行,保存。
2.3 perlbrew 安装 perl
代码如下:
[root@ithomer ~]# perlbrew available
# perl
perl-5.36.0
perl-5.34.1
perl-5.32.1
perl-5.30.3
perl-5.28.3
perl-5.26.3
perl-5.24.4
perl-5.22.4
i perl-5.20.3
perl-5.18.4
perl-5.16.3
perl-5.14.4
perl-5.12.5
perl-5.10.1
perl-5.8.9
perl-5.6.2
# cperl
我这个上面有一个 i ,因为我之前已经安装好了版本perl-5.20.3,你那上面应该是没有的
然后依次按行执行下面代码:
我这里安装的是5.20.3,看个人需求安装
// 安装 perl-5.20.3
[root@ithomer ~]# perlbrew install perl-5.20.3
// 切换到当前版本perl
[root@ithomer ~]# perlbrew switch perl-5.20.3
// 查看当前有的 perl
[root@ithomer ~]# perlbrew list
* perl-5.20.3
// 查看 perl 版本
[root@ithomer ~]# perl -v/p
This is perl 5, version 20, subversion 3 (v5.20.3) built for x86_64-linux
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2015, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.