简体   繁体   中英

How can I install Perl module without using CPAN.pm?

Is it possible?

If you download the source code, and read the README file. This will probably tell you you should do

perl Makefile.PL
make
make test
make install

or

perl Build.PL
./Build
./Build test
./Build install

If you download the source code, it will generally have a Makefile.PL. You run "perl Makefile.PL; make; make test; make install" and it will build and install for you.

Obviously if you're not using CPAN.pm, you're going to have to deal with dependencies yourself.

Also, if the reason you can't use CPAN.pm is that you don't have permission to install into /usr/lib/perl, you can force CPAN.pm to install locally, but I forget how.

If you are on a Linux box, a very large portion of the packages can usually be obtained using the built in package manager. For instance, on an Ubuntu system, if you want to install the PostgreSQL Perl module you'd simple do:

sudo apt-get install libpg-perl

You can see a list of the modules for Ubuntu here: http://packages.ubuntu.com/hardy/perl/

I find I can often guess at the names myself. Not sure if this helps at all, but for myself I often find this easier to use than CPAN as it does a lot better at resolving dependencies.

See here: How to install perl modules using CPAN without root

I have just set this up on a server without root access and CPAN does everything automatically.

But if you really wanna install a module without CPAN and you don't have root (assuming this since you don't wanna use CPAN), you can do it as follows

perl Makefile.PL PREFIX=$HOME
make
make install

You're gonna have to hunt down dependencies yourself so it's better to use CPAN.

If the problem is no root access, I would recommend looking at local::lib and also this webpage for CPAN.pm and non-root installation.

But to answer the question as asked, CPAN or CPANPLUS are helpful, but they aren't required. You can always do it the old-fashioned way as Leon says - though usually, it's easier not to.

If the.pm file is pure Perl and doesn't need to be compiled you can just put it in your application's lib folder and use it as normal.

If you are using Red Hat (Fedora, CentOS), you should use RPM for Perl dependencies wherever possible. Perl packages are almost always named perl-Module-Name, eg perl-DBI, perl-Spreadsheet-WriteExcel, etc.

On Ubuntu the naming scheme is libmodule-name-perl.

We can install all perl modules both from and even with your terminal in ubuntu. If you are using a ubuntu server then execute the following command, 'sudo apt-get install "perl_module"' The modules which you want just give the name in "perl_module" means If you want to install Apache2::Cookie it will be in "libapreq2" so you have to give like, "sudo apt-get install libapreq2"

If you're asking this because you're having problems with CPAN... you're probably running out of RAM that's why you can't use CPAN.

Maybe you don't have a swap file. Try this:

$ sudo su
# dd if=/dev/zero of=/swap bs=1M count=1k # create a 1GB file
# mkswap /swap
# swapon /swap

Otherwise... stop some services.

$ sudo service mysql stop
$ sudo service nginx stop

...And try again

$ cpan install CPAN
$ cpan install MIME::Lite::TT::HTML

I, as others have would highly suggest using CPAN.pm. It is a breeze to use and can resolve any dependencies associated with the module you need automatically.

On the other hand, I would suggest that you read the perlmodinstall document over at perldoc as it gives details on other os' as well.

Regards,

Jeff

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM