Tropical Software Observations

27 August 2009

Posted by Unknown

at 1:29 PM


Labels: , , , ,

Install Apache-Passenger (mod_rails) on Ubuntu 9.04 in 10 steps

A very quick guide on installing Passenger (mod_rails) on a clean install of Ubuntu jaunty 9.04.

  1. apt-get install build-essentials
  2. apt-get ruby apt-get ruby-dev
  3. gem install rubygems-update
  4. cd /var/lib/gems/1.8/rubygems-update-1.3.x/
  5. ruby setup.rb or bin/update_rubygems
  6. gem update --system
  7. gem update
  8. gem install passenger
  9. apt-get install libopenssl-ruby1.8 apache2-prefork-dev libaprutil1 libaprutil1-dev
  10. passenger-install-apache2-module
At the end of the installation, you will be prompted to add a few lines to your apache conf -- copy and paste the lines to /etc/apache2/apache2.conf and you are ready to deploy Rails apps immediately.

For the rest of the setup and configuration see here. Hope this helps someone out there.

04 August 2009

Posted by Irregular Zero

at 4:28 PM


Labels: , ,

Groovy Tutorial for MongoDB

Java Tutorial (

Since Groovy is based on Java, you can make use of the Java driver for MongoDB as well as go through the tutorial shown above. The code can be used as-is or modified to look more groovy.

Create a groovy file (mongo.groovy) and place the Java driver in the same directory. Edit it so the code looks like:

this.class.classLoader.rootLoader.addURL(new File("mongo-0.6.jar").toURL())

import com.mongodb.*

DBAddress address = new DBAddress("localhost", "mydb")
Mongo db = new Mongo(address)
db.authenticate('testUser', 'testPassword')

DBCollection coll = db.getCollection("testCollection")

BasicDBObject doc = new BasicDBObject()
doc.put("name", "MongoDB")
doc.put("type", "database")
doc.put("count", 1)

BasicDBObject info = new BasicDBObject()
info.put("x", 203)
info.put("y", 102)
doc.put("info", info)


for(i in 1..100) {
coll.insert(new BasicDBObject().append("i", i))

println coll.getCount()

DBCursor cursor = coll.find()
while(cursor.hasNext()) {

You can see it's just a rehash of part of the Java tutorial, the output will be a count of the number of inserted objects followed by the objects themselves.

The first line of code loads the jar file, this is useful if you're not looking to put the jar in a classpath or one of groovy's configured library paths like '~/.groovy/lib'.

Running the script is accomplished by 'groovy mongo.groovy' in the terminal. You can also type in 'groovyConsole' to load the console then opening the script and running inside it.

Installing MongoDB on Ubuntu 9.04 Jaunty Jackalope

For the installation, I decided to build MongoDB ( from source. The documentation regarding this is thorough and getting it running was a cinch. A Javascript engine called Spider Monkey is used and you need to build it with UTF8 support.

The documents referred to:

The all-in-one command line version:
sudo apt-get install curl tcsh git-core scons g++
sudo apt-get install libpcre++-dev libboost-dev libmozjs-dev

Spider Monkey installation:
curl -O
tar zxvf js-1.7.0.tar.gz
cd js/src
make -f Makefile.ref
sudo JS_DIST=/usr make -f Makefile.ref export

MongoDB installation:
git clone git://
scons all
sudo scons --prefix=/opt/mongo install

Finishing up:
add /opt/mongo/bin to your path
create a /data/db directory structure and chown it to your user or add read-write permission.
System -> Preferences -> Startup Applications -> Startup Programs
click add, click browse and select /opt/mongo/bin/mongod
add run to the end of the line so that it reads '/opt/mongo/bin/mongod run'
enter name and comment then save

And you're done. mongodb will start up with no authentication as default at localhost:27017, the web information interface is at localhost:28017. You can use mongo to enter the interactive shell, similar to mysql's shell client.

Some links to get you started: