免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4928 | 回复: 4
打印 上一主题 下一主题

perl 如何用非ROOT权限安装模块且如何使用? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-01-09 18:41 |只看该作者 |倒序浏览
RT

论坛徽章:
0
2 [报告]
发表于 2011-01-09 18:58 |只看该作者
use local::lib
这里有篇非常漂亮的介绍文档:
http://perl.jonallen.info/writin ... odules-without-root

论坛徽章:
0
3 [报告]
发表于 2011-01-09 18:59 |只看该作者
非  root 权限的话,只是不能将模块安装到 /usr/ 下面了, 不过可以配置 cpan 指定安装的目录的,那在使用的时候当然要将这个目录添加到 PERL5LIB 环境变量就可以了, 或是直接在脚本里面使用 use lib 当然也可以了

论坛徽章:
0
4 [报告]
发表于 2011-01-09 22:01 |只看该作者
use local::lib
这里有篇非常漂亮的介绍文档:
兰花仙子 发表于 2011-01-09 18:58



   
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~

论坛徽章:
0
5 [报告]
发表于 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.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP