If you’ve been reading up on the various NoSQL offerings and have wanted to try out one but don’t know how to get started, this is one of the easiest ways. I chose MongoDB for this example because I’m going to start using it for a project that needs features that MySQL isn’t as fast at: namely denormalized data with billions of rows. MongoDB has plenty of drivers for other scripting and high-level languages but I’ll focus on the PHP driver today. If there is interest I can do a write up on Python usage later. This example is limited to CentOS, Fedora, and Redhat 5 servers that use the yum package management system. For more information you can reference their download page: http://www.mongodb.org/display/DOCS/Downloads
First install the prerequisites:
- sudo yum install gcc php php-pear
Then install the mogo php extension via pecl and add the extension to the ini file. (Increase the php.ini memory_limit to 32M if necessary). Then we restart apache to have the extension loaded. You can check your extensions via the phpinfo(); command in php.
- sudo pecl install mongo
- sudo echo “extension=mongo.so” >> /etc/php.ini
- sudo /etc/init.d/httpd restart
For the last part we add the yum repo and get the actual MongoDB server and client installed
- cd /etc/yum.repos.d
- sudo emacs mongodb.10gen.repo
- paste in the following. This uses the repo for 64bit servers. See their download page for other architecture repo settings.
- sudo yum install mongo-stable-server
- sudo /etc/init.d/monod start
- chkconfig mongod on
[10gen]
name=10gen Repository
baseurl=http://downloads.mongodb.org/distros/centos/5.4/os/x86_64/
gpgcheck=0
That’s it, you’re ready to start using Mongo! You can check the logfile to make sure things are running smoothly: “sudo cat /var/log/mongo/mongod.log”







Thanks for this, made life easy getting this installed!
[root@25115_2_71849_311688 yum.repos.d]# service mongod start
/etc/init.d/mongod: line 25: /etc/sysconfig/mongod: No such file or directory
Starting mongod: runuser: user mongod does not exist
[root@25115_2_71849_311688 yum.repos.d]# [FAILED]
PLEASE HELP? Centos 64-bit 5.5
You probably need to make sure that the “mongod” user was created. You can check via: $> grep “mongod” /etc/passwd
If there is no user then add the user via: $> useradd mongod
Thanks… very helpful.
FYI, this line has a typo: sudo /etc/init.d/monod start
and should be: sudo /etc/init.d/mongod start
thanks I needed this it helped me speed up my install. barring for the fact that maybe you should publish an updated version for this. It would help a lot of lost folks. minor things changed which isnt hard to figure out anyway.
thanks for the time to publish this.