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:
Which connected me to MongoDB, showing:
when I loaded the page!
4 thoughts on “Got Mongo Working on Hostmonster!”
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.
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 mongo.so ended up in.
I actually followed these instructions for the mongo installation:
For the PHP Driver, okay, it may work, but I have the problem that I am on Shared hosting, and can not leave the “mongod” server running all the time. Also from Hostmonster told me that they do not plan to support NoSQL databases, so I left this as an option with them.
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!