Got Mongo Working on Hostmonster!

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:

  1. 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.
  2. Run:
    $ tar zxvf mongodb-linux-i686-old-linux-1.tgz
  3. Make a directory for the database to put files in:
    $ mkdir /home/user/data
  4. Upload libjava.so, libjvm.so, and libverify.so. Make sure they have execute permissions and put them somewhere like /home/user/lib.
  5. Run:
    $ export LD_LIBRARY_PATH=/home/user/lib

    replacing the path wherever you put the .so’s above.

  6. 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:


Which connected me to MongoDB, showing:

localhost:27017

when I loaded the page!

Another comic

I finally put up another comic. I’ve been delayed for two reasons: first, I’ve been really busy with work. I’ve done some major work on the PHP driver, so it should now be easily installable on Linux and Mac (it’s also faster).

Second, I’ve been wanted to add a “one shot gag” section, which requires some fairly major rewriting of my site code, so I tried to get Git set up on Hostmonster (my hosting provider). I got it set up fine, but the money-grubbing jerks at Hostmonster block outgoing ssh unless you pay for a dedicated IP. So, I can’t put the source of my site on Github, which is sad. However, at least I have Git set up locally, so I don’t have to worry about breaking stuff.

Anyway, hope people enjoy the one-shots. More coming.