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:
for i in `echo Params-Validate-1.06-kNaYxh
sudo perl Makefile.PL
sudo make install
Since it is already sorted, the installation goes smoothly without errors. After the installation, do the test:
$ perldoc MongoDB
It is done! very cool.