Got Mongo Working on Hostmonster!

This was written in April of 2009. It is very out of date. See 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,, and 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:


when I loaded the page!

4 thoughts on “Got Mongo Working on Hostmonster!

  1. Hi Kristina,

    when installing the PHP Driver as by the given “install instructions”

    did you follow the manual installation or use the “pecl install mongo” command?

    With the manual installation I get the following error:
    Installing shared extensions: /usr/lib64/php/modules/
    cp: cannot create regular file `/usr/lib64/php/modules/#INST@18179#’: Read-only file system

    With the “pecl” command, this error:
    checking whether the C compiler works… configure: error: cannot run C compiled programs.



  2. These instructions are incredibly out-of-date (this was written over a year ago). I’ll add a warning at the top of the post.

    You can’t use PECL (as far as I know) on Hostmonster. I downloaded the driver’s source, compiled it, DID NOT install it, and then modified php.ini to set extension_dir to the local directory ended up in.


  3. Yeah, I ran into the same problem with them killing MongoDB after 5 minutes. You can get a dedicated IP and they’ll let it run, but that’s not a workable solution for me (I’m cheap). Hostmonster seems like a pretty hidebound company.

    Edit: if enough people bug them, though, maybe they’ll start supporting stuff like Mongo, so thanks!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: