MongoDB is an open-source document database designed for easy of development and scaling. For more information please visit www.mongodb.org , You can also download the linux tar file for manual installation as per your customized needs. Today i had a chance to install MongoDB on one of our cpanel based server so just wanted to write down how its installed.
Step 1.) Installing repo
[root / ]# cd /etc/yum.repos.d
[root / ]# nano -w mongodb.repo
Copy and Paste the below given code and save the file.
[mongodb]
name=MongoDB Repo
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1
Step 2.) Installing the package MongoDB
[root / ]# yum install mongo-10gen mongo-10gen-server
Step 3.) Configure it to automatically start after reboots
[root / ]# chkconfig mongod on
Start MongoDB:
[root / ]# service mongod start
Starting mongod: [OK]
Step 4.) Installing MongoDB PHP Extension
[root / ]# pecl install mongo
Let the process complete and at the end you should see the following text.
….
Build complete.
Don’t forget to run ‘make test’.
running: make INSTALL_ROOT=”/root/tmp/pear/pear-build-rootv6pAQg/install-mong-1.6.13″ install
Installing shared extensions: /root/tmp/pear/pear-build-rootv6pAQg/install-mongo-1.6.13/usr/local/lib/php/extensions/no-debug-non-zts-20121212/
running: find “/root/tmp/pear/pear-build-rootv6pAQg/install-mongo-1.6.13” | xargs ls -dils
6292373 4 drwxr-xr-x 3 root root 4096 Apr 9 02:58 /root/tmp/pear/pear-build-rootv6pAQg/install-mongo-1.6.13
6292524 4 drwxr-xr-x 3 root root 4096 Apr 9 02:58 /root/tmp/pear/pear-build-rootv6pAQg/install-mongo-1.6.13/usr
6292525 4 drwxr-xr-x 3 root root 4096 Apr 9 02:58 /root/tmp/pear/pear-build-rootv6pAQg/install-mongo-1.6.13/usr/local
6292526 4 drwxr-xr-x 3 root root 4096 Apr 9 02:58 /root/tmp/pear/pear-build-rootv6pAQg/install-mongo-1.6.13/usr/local/lib
6292527 4 drwxr-xr-x 3 root root 4096 Apr 9 02:58 /root/tmp/pear/pear-build-rootv6pAQg/install-mongo-1.6.13/usr/local/lib/php
6292528 4 drwxr-xr-x 3 root root 4096 Apr 9 02:58 /root/tmp/pear/pear-build-rootv6pAQg/install-mongo-1.6.13/usr/local/lib/php/extensions
6292529 4 drwxr-xr-x 2 root root 4096 Apr 9 02:58 /root/tmp/pear/pear-build-rootv6pAQg/install-mongo-1.6.13/usr/local/lib/php/extensions/no-debug-non-zts-20121212
6292523 1836 -rwxr-xr-x 1 root root 1878374 Apr 9 02:58 /root/tmp/pear/pear-build-rootv6pAQg/install-mongo-1.6.13/usr/local/lib/php/extensions/no-debug-non-zts-20121212/mongo.so
Build process completed successfully
Installing ‘/usr/local/lib/php/extensions/no-debug-non-zts-20121212/mongo.so’
install ok: channel://pecl.php.net/mongo-1.6.13
Extension mongo enabled in php.ini
Restart Apache to apply changes:
[root / ]# service httpd restart
Verify installation with this command:
[root / ]# php -i | grep mongodb -i
MongoDB Support => enabled
MONGODB-CR => enabled
MONGODB-X509 => enabled
mongo.allow_empty_keys => 0 => 0
mongo.chunk_size => 261120 => 261120
mongo.cmd => $ => $
mongo.default_host => localhost => localhost
mongo.default_port => 27017 => 27017
mongo.is_master_interval => 15 => 15
mongo.long_as_object => 0 => 0
mongo.native_long => 1 => 1
mongo.ping_interval => 5 => 5
If you see the MongoDB extension in the output, That’s it you are all set.
Note: This was installed on CentOS release 6.7 (Final) Cpanel based server. Installing it with the yum manager was lot easier and quicker.