MongoDB Driver Installation for PHP




I was just wondering if there was any way to install the mongo driver for PHP for development. I have tried by installing Mongo manually, and including the extension (“”) in a ‘php.ini’ file, but I have had no luck… And help would be appreciated. There is an error when attempting to start apache after including the extension in the php.ini;

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20121212/' - /usr/lib/php5/20121212/ cannot open shared object file: No such file or directory in Unknown on line 0

Thank you in advance.


Hey @aaronjamesmarshallau,

So you followed these install steps seen in the docs here:

I’d say check out the official C9 MongoDB docs too and this SO:

:books: :snail:


Hey @mikeumus,

I followed those steps exactly, installing Mongo and adding the extension in my ini file. This is what generates the aforementioned error. I also saw the other two articles you suggested, but neither explicitly help with installing the PHP driver for MongoDB on C9.

Thank you very much for your help, but unfortunately it has not resolved my issue.


For anyone curious - I did manage to fix this myself. There were a couple of steps.
First, you must install SASL - required for building MongoDB. Upon attempting an install, you will receive the error:

configure: error: sasl.h not found!

This means that we don’t have SASL installed.

sudo apt-get install libsasl2-dev

After installing this, we can install MongoDB’s PHP driver.

sudo pecl install mongodb

This should install successfully this time! After that, you simply need to create a php.ini file in your workspace root directory. Add the following line, and you’re done!

Hopefully that helps!


Good persistance @aaronjamesmarshallau !

Glad you got mongodb working.

:hand: :smiley: :leaves: