This was written in April of 2009. It is very out of date. See http://rcrisman.net/article/11/installing-mongodb-on-hostmonster-bluehost-accounts for more up-to-date information (as of August 2010). Keep in mind that shared hosting with Hostmonster is very lame. They only lets you run a program for 5 minutes before killing it, so it’s fairly useless to install MongoDB unless you have a dedicated IP.
I finally got MongoDB working on this site, so I’m going to start switching stuff over from MySQL. I’m biased, but I think it’s just an easier database to use.
And, because I like writing tutorials… How I did it:
- Downloaded the binary I created of MongoDB for “legacy” Linux. I originally compiled this for a user on Mandriva 2006 (see previous post about VMWare), but it works fine for other old Linux distros, too.
$ tar zxvf mongodb-linux-i686-old-linux-1.tgz
- Make a directory for the database to put files in:
$ mkdir /home/user/data
- Upload libjava.so, libjvm.so, and libverify.so. Make sure they have execute permissions and put them somewhere like /home/user/lib.
$ export LD_LIBRARY_PATH=/home/user/lib
replacing the path wherever you put the .so’s above.
- Start the database:
$ cd mongodb-linux-i686-old-linux-1 $ bin/mongod --dbpath /home/user/data --nojni run
I cheated a bit and didn’t install Java, so I had to use the –nojni option. If you install Java, you won’t need that (and you won’t need to upload the individual .so files).
Now, what good is a database if you can’t use it, right? So, I downloaded my PHP driver (go to its Github repository and click “Download” for the latest version). I then followed the install instructions and put the .so generated by
make in /home/user/extensions.
I changed the options under “PHP Config” in Hostmonster’s CPanel to use php.ini in /home/user/public_html/php.ini, and then edited that file to use my extension.
I made a simple test page with:
<?php include "Mongo.php"; $m = new Mongo(); echo $m; ?>
Which connected me to MongoDB, showing:
when I loaded the page!