ztj2247 发表于 2011-01-09 18:41

perl 如何用非ROOT权限安装模块且如何使用?

RT

兰花仙子 发表于 2011-01-09 18:58

use local::lib
这里有篇非常漂亮的介绍文档:
http://perl.jonallen.info/writing/articles/install-perl-modules-without-root

socyno 发表于 2011-01-09 18:59

非root 权限的话,只是不能将模块安装到 /usr/ 下面了, 不过可以配置 cpan 指定安装的目录的,那在使用的时候当然要将这个目录添加到 PERL5LIB 环境变量就可以了, 或是直接在脚本里面使用 use lib 当然也可以了

ztj2247 发表于 2011-01-09 22:01

use local::lib
这里有篇非常漂亮的介绍文档:
兰花仙子 发表于 2011-01-09 18:58 http://bbs.chinaunix.net/images/common/back.gif


    anything with a version of v5.8.9 or earlier, you should really ask your system administrator or OS vendor for an upgrade. Perl 5 version 10.0

好郁闷。。俺的PERL是 v5.8.8的~没权限升级 FT~

socyno 发表于 2011-01-09 22:55

CPAN 文档中找到的



I am not root, how can I install a module in a personal directory?

First of all, you will want to use your own configuration, not the one that your root user installed. If you do not have permission to write in the cpan directory that root has configured, you will be asked if you want to create your own config. Answering "yes" will bring you into CPAN's configuration stage, using the system config for all defaults except things that have to do with CPAN's work directory, saving your choices to your MyConfig.pm file.

You can also manually initiate this process with the following command:

    % perl -MCPAN -e 'mkmyconfig'
or by running

    mkmyconfig
from the CPAN shell.

You will most probably also want to configure something like this:

o conf makepl_arg "LIB=~/myperl/lib \
                  INSTALLMAN1DIR=~/myperl/man/man1 \
                  INSTALLMAN3DIR=~/myperl/man/man3 \
                  INSTALLSCRIPT=~/myperl/bin \
                  INSTALLBIN=~/myperl/bin"
and then the equivalent command for Module::Build, which is

o conf mbuildpl_arg "--lib=~/myperl/lib \
                  --installman1dir=~/myperl/man/man1 \
                  --installman3dir=~/myperl/man/man3 \
                  --installscript=~/myperl/bin \
                  --installbin=~/myperl/bin"
You can make this setting permanent like all o conf settings with o conf commit or by setting auto_commit beforehand.

You will have to add ~/myperl/man to the MANPATH environment variable and also tell your perl programs to look into ~/myperl/lib, e.g. by including

use lib "$ENV{HOME}/myperl/lib";
or setting the PERL5LIB environment variable.

While we're speaking about $ENV{HOME}, it might be worth mentioning, that for Windows we use the File::HomeDir module that provides an equivalent to the concept of the home directory on Unix.

Another thing you should bear in mind is that the UNINST parameter can be dangerous when you are installing into a private area because you might accidentally remove modules that other people depend on that are not using the private area.



页: [1]
查看完整版本: perl 如何用非ROOT权限安装模块且如何使用?