Updated July 2012. (Originally published in December 2010).
In your DreamHost Panel, make sure your domain is running PHP 5.3. If you’re not sure which version to pick, choose
PHP 5.3.x FastCGI
SSH to your server and download the latest MongoDB PHP driver:
curl -L -o mongo-php-driver.tar.gz https://github.com/mongodb/mongo-php-driver/tarball/master
Extract the source code:
tar zxvf mongo-php-driver.tar.gz
Run phpize using 5.3:
Configure using PHP 5.3:
(You should now have a compiled
mongo.so extension in the
Create this directory:
mkdir -p ~/.php/5.3
Move your newly compiled module into that directory:
mv modules/mongo.so ~/.php/5.3/
Create a phprc file:
echo "extension = /home/`whoami`/.php/5.3/mongo.so" >> ~/.php/5.3/phprc
Restart your PHP process(es) to pickup the new directives in your phprc:
You should now see the mongo extension listed when you run a
Let me know how this works for you in the comments below!
Note: These instructions work well for connecting to a hosted instance of MongoDB, like MongoHQ. DreamHost terms of service prevent you from running your own MongoDB service on a shared hosting plan. In order to run a legit MongoDB server, you’ll probably need to upgrade to a DreamHost VPS.