William Jiang

JavaScript,PHP,Node,Perl,LAMP Web Developer – http://williamjxj.com; https://github.com/williamjxj?tab=repositories

CentOS 6.2: Install Perl’s MongoDB modules without CPAN

Install Perl’s MongoDB module on CentOS 6.2

I already setup MongoDB server in CentOS 6.2 server, and want to add Perl client-side, just like PHP’s client side.
It is somewhat painful to install Perl modules without CPAN because CentOS doesn’t install it by default.

It is a little challenge to install MongoDB.pm without CPAN. However, it’s Perl, should be no problem.
I pre-installed a 32-bit xampp package in this CentOS; it has a 32-bit cpan and perl which I can use. It can’t compile with the system, but can be used to download Perl’s modules.

(1) So, first step, use xmapp’s cpan command to download all dependent modules from CPAN repository:
$ sudo /opt/lampp/bin/cpan MongoDB

(2) Now all the dependant modules are downloaded but could not installed, but compile are failed: because the OS is 64-bit while lamp is 32-bit, 32-bit /opt/lampp/bin/perl, make can’t compile these modules into 64-bits OS systems.
I have to use CentOS’ perl, make instead.

$ cd /root/.cpan/build/
$ ls -lrt | grep ^d 
# to get all MongoDB's dependant modules to a file '/tmp/1234'
# Notice the sequence are very important, so use 'ls -lrt'
$ cd /tmp/
$ cat 1234 | cut -f11 -d ' ' >/tmp/process.sh

(3) To do some vi process, generate file like this:

#!/bin/bash
cd /root/.cpan/build/
for i in `echo Params-Validate-1.06-kNaYxh 
DateTime-0.77-lWIhS7 
Data-Types-0.09-0jo_xI 
Class-Method-Modifiers-1.09-CogBmd 
blah blah...
MongoDB-0.46.3-p4xRQm`
do
    echo $i
    cd $i
    sudo perl Makefile.PL
    sudo make
    sudo make install
    cd -
done

Since it is already sorted, the installation goes smoothly without errors. After the installation, do the test:
$ perldoc MongoDB
It is done! very cool.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: