How To Install MongoDB on Ubuntu Server

Monday, March 8, 2010

Initial user and directory setup

Before installing anything, I'm going to prepare some necessary
directories and create the mongodb user:

sudo adduser mongodb
# for the mongodb data files:
sudo mkdir /var/lib/mongodb
# for the log files:
sudo mkdir /var/log/mongodb
sudo chown mongodb /var/lib/mongodb/

Install dependencies

Install the needed dependencies for building MongoDB from source:

sudo apt-get -y install tcsh git-core scons g++
sudo apt-get -y install libpcre++-dev libboost-dev libreadline-dev xulrunner-1.9.1-dev

MongoDB uses SpiderMonkey for server-side Javascript execution. The
mongod project requires a file js.lib when linking. This page details
how to build js.lib.

#download
curl -O ftp://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz
tar zxvf js-1.7.0.tar.gz
#build
cd js/src
export CFLAGS="-DJS_C_STRINGS_ARE_UTF8"
make -f Makefile.ref
#install
sudo JS_DIST=/usr make -f Makefile.ref export

Build MongoDB

git clone git://github.com/mongodb/mongo.git
scons all
sudo scons --prefix=/usr/local/mongo install

Now, create the init.d script file to have MongoDB start up on a reboot.

sudo vim /etc/init.d/MongoDB
# my version of this script is here: http://gist.github.com/324781
# make init script executable:
sudo chmod +x /etc/init.d/MongoDB
# set up runtime links:
sudo update-rc.d MongoDB defaults

And to get it up and running, just run the init script:

sudo /etc/init.d/MongoDB start

For http access, add 1000 to the port:
http://localhost:28017/

References

Here are some references that helped a lot in getting my own setup
working:
- Quickstart
- Building for
Linux

- Building Spider
Monkey

- Installing MongoDB on Ubuntu 9.04 Jaunty
Jackalope

Python Driver

  • install pymongo
  • API

This entry was tagged Linux and mongodb

comments powered by Disqus

© 2009-2013 lxneng.com. All rights reserved. Powered by Pyramid

go to Top