如何以非root用户身份使用CPAN? [英] How can I use CPAN as a non-root user?
问题描述
我想在没有root用户访问权限的共享服务器上安装perl模块.我怎样才能做到这一点?他们似乎还具有较旧的CPAN版本(运行该命令时会抱怨),是否可以从我的帐户更新正在使用的CPAN命令而无需root访问权限?
I want to install perl modules on a shared server on which I do not have root access. How can I do this? They also seem to have an older version of CPAN (it complains about that when running the command), is it possible to update the CPAN command being used from my account without requiring root access?
推荐答案
到目前为止,我发现的最简单的方法是说
The easiest method I have found so far is to say
wget -O- http://cpanmin.us | perl - -l ~/perl5 App::cpanminus local::lib
eval `perl -I ~/perl5/lib/perl5 -Mlocal::lib`
echo 'eval `perl -I ~/perl5/lib/perl5 -Mlocal::lib`' >> ~/.profile
echo 'export MANPATH=$HOME/perl5/man:$MANPATH' >> ~/.profile
这假设您的配置文件名为.profile
,您可能需要将其更改为.bash_profile
,.bashrc
等.之后,您可以通过说出安装模块的方式
This assumes your profile is named .profile
, you may need to change that to be .bash_profile
, .bashrc
, etc. After that you can install modules by saying
cpanm Module::Name
并以与将它们安装在根目录中时相同的方式使用它们.
and simply use them the same way you would if the were installed in the root directories.
下面是对上述命令的简要说明.
What follows is a brief explanation of what the commands above do.
wget -O- http://cpanmin.us
获取最新版本的cpanm
并将其打印到STDOUT
,然后将其通过管道传输到perl - -l ~/perl5 App::cpanminus local::lib
.第一个-
告诉perl
期望程序会出现在STDIN
上,这使perl
运行我们刚刚下载的cpanm
版本. perl
将其余参数传递给cpanm
. -l ~/perl5
参数告诉cpanm
Perl模块的安装位置,另外两个参数是两个要安装的模块. [App::cpanmins
] 1 是安装cpanm
. local::lib
是管理环境的帮助程序模块在本地目录中运行模块所需的变量.
wget -O- http://cpanmin.us
fetches the latest version of cpanm
and prints it to STDOUT
which is then piped to perl - -l ~/perl5 App::cpanminus local::lib
. The first -
tells perl
to expect the program to come in on STDIN
, this makes perl
run the version of cpanm
we just downloaded. perl
passes the rest of the arguments to cpanm
. The -l ~/perl5
argument tells cpanm
where to install Perl modules, and the other two arguments are two modules to install. [App::cpanmins
]1 is the package that installs cpanm
. local::lib
is a helper module that manages the environment variables needed to run modules in local directory.
在安装了这些模块之后,我们将运行
After those modules are installed we run
eval `perl -I ~/perl5/lib/perl5 -Mlocal::lib`
设置使用本地模块所需的环境变量,然后
to set the environment variables needed to use the local modules and then
echo 'eval `perl -I ~/perl5/lib/perl5 -Mlocal::lib`' >> ~/.profile
以确保我们下次登录时可以使用它们.
to ensure we will be able to use them the next time we log in.
echo 'export MANPATH=$HOME/perl5/man:$MANPATH' >> ~/.profile
有望使man找到您本地模块的手册页.
will hopefully cause man to find the man pages for your local modules.
这篇关于如何以非root用户身份使用CPAN?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!