From my older blog. Originally posted Oct 26th 2012
I had to walk through all of this to get setup for my Mongo Developer and Administrator certification classes. I figured I might help you out and put it all together instead of you having to hunt all over the place for this info.
Lets get started…
Step 1: Install MongoDB
To install MongoDB on your fedora system, issue the following commands in your terminal:
su -
Lets make sure that mongo hasnt already been installed while you were playing around with it…
yum -y remove libmongodb mongodb mongodb-server
Setup the mongodb repo…
vi /etc/yum.repos.d/10gen.repo
For 32 Bit, place the following code on that file:
http://gist.github.com/3949816#file_32bit.repo
and for 64 Bit this one:
http://gist.github.com/3949816#file_64bit.repo
Installation…
Run these two commands.
yum install mongo-10gen mongo-10gen-server mongod -f /etc/mongod.conf
Then open your Mongo Shell in terminal (to ensure it’s functional) with:
mongo
and close it by pressing Ctrl+C; Then add the mongo service to the system’s startup with:
chkconfig --levels 235 mongod on
Reboot and reopen the Mongo Shell with the command:
mongod -f /etc/mongod.conf && mongo
Close it with Ctrl+C and then go to:
http://localhost:27017/
In your web browser, you should see something like this:
“You are trying to access MongoDB on the native driver port. For http diagnostic access, add 1000 to the port number”
If you see this then you have it installed and setup correctly.
Step2. Installing Python, Pymongo, and Python-Bottle
First a little background…
Python – Python is a general-purpose, interpreted high-level programming language whose design philosophy emphasizes code readability. Its syntax is said to be clear and expressive.Python has a large and comprehensive standard library. More info can be found here: http://www.python.org/
Pymongo – PyMongo is a Python distribution containing tools for working with MongoDB, and is the recommended way to work with MongoDB from Python. More info can be found here: http://api.mongodb.org/python/current/
Bottle – Bottle is a fast, simple and lightweight WSGI micro web-framework for Python. It is distributed as a single file module and has no dependencies other than the Python Standard Library. More info is here: http://bottlepy.org/docs/dev/
If you haven’t already you need to install the EPEL repo for Centos 6
Check to see if you already have it installed or not…
yum repolist
You will see something similar to this:
repo id repo name status base CentOS-6 - Base 6,294 extras CentOS-6 - Extras 4 updates CentOS-6 - Updates 830 repolist: 7,128
Since you dont see it above you need to grab the package…
http://mirror.us.leaseweb.net/epel/6/i386/repoview/epel-release.html
-OR-
wget "http://mirror.us.leaseweb.net/epel/6/i386/epel-release-6-7.noarch.rpm"
Note… the version number in the rpm name…if you are looking at this very late after the pub date of this post then you likely need to grab a more current version. Just follow the link above and you should see it.
do this next to test the rpm…
rpm -ivh epel-release-6-5.noarch.rpm --test
You will get back a NO KEY message.
You now need to download and install the key from FedoraProject and install on your system…
wget https://fedoraproject.org/static/0608B895.txt mv 0608B895.txt /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Verify that the key got installed successfully…
rpm -qa gpg* gpg-pubkey-0608b895-4bd22942
Now install the epel-release-6-6.noarch package, which will enable EPEL repository on your system…
rpm -ivh epel-release-6-5.noarch.rpm
Now verify that the EPEL repo is working correctly…
yum repolist
You should see a line that looks similar to this:
epel Extra Packages for Enterprise Linux 6 - x86_64 7,345
Now lets get Python, Pymongo and Bottle setup…
Pretty simple and straight forward…
sudo yum -y install python python-setuptools python-setuptools-devel sudo yum -y install python-bson pymongo pymongo-gridfs
To install bottle you may need to install PIP first…
You can do this using curl and python…
curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python
Then install bottle…
pip install bottle
This post saved my day… and just one thing you are installing python-bson separately, and pymongo comes with the bson package, so no need of that…