For driver developers and people interested in the latest bugfixes, you can compile the driver from the latest source code on ยป Github. Run the following commands to clone and build the project:
$ git clone https://github.com/mongodb/mongo-php-driver.git $ cd mongo-php-driver $ git submodule sync && git submodule update --init $ phpize $ ./configure $ make all -j 5 $ sudo make install
The last step will report where mongodb.so has been installed, similar to:
Installing shared extensions: /usr/lib/php/extensions/debug-non-zts-20151012/
Ensure that the extension_dir option in php.ini points to the directory where mongodb.so was installed. You can query the option by running:
$ php -i | grep extension_dir extension_dir => /usr/lib/php/extensions/debug-non-zts-20151012 => /usr/lib/php/extensions/debug-non-zts-20151012
If the directories differ, either change extension_dir in php.ini or manually move mongodb.so to the correct directory.
Add the following line to your php.ini file:
extension=mongodb.so