MongoDB Driver Installation for PHP

php
customization

#1

Hello.

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 (“extension=mongodb.so”) 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/mongodb.so' - /usr/lib/php5/20121212/mongodb.so: cannot open shared object file: No such file or directory in Unknown on line 0

Thank you in advance.


#2

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:


#3

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.


#4

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!

extension=mongodb.so

Hopefully that helps!


#5

Good persistance @aaronjamesmarshallau !

Glad you got mongodb working.

:hand: :smiley: :leaves: