MongoDB in PHP Installation

Last modified: 
Thursday, April 2nd, 2015

Installing MongoDB with PHP support for same

Installing libraries with Apt-Get

# Install mongodb
sudo apt-get install mongodb

# Install PHP PEAR
sudo apt-get install php-pear

# Install SASL
sudo apt-get install libsasl2-dev

# Install PHP support for MongoDB
sudo pecl install mongodb

Add "" to php.ini

I'm doing this on an old Ubuntu 12 build, so on that you'd probably add the line to /etc/php5/apache2/php.ini. I'll put instructions for up to date servers later tonight.

Restart Apache2

sudo service apache2 restart

configure: error: sasl.h not found!

Installing MongoDB with Pecl with command sudo pecl install mongo fails with error

checking for SASL... not found
configure: error: sasl.h not found!

Likely Solution
Ensure the SASL library is installed

sudo apt-get install libsasl2-dev

The operator of this site makes no claims, promises, or guarantees of the accuracy, completeness, originality, uniqueness, or even general adequacy of the contents herein and expressly disclaims liability for errors and omissions in the contents of this website.