Manually Installing the MongoDB PHP Driver
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 update --init $ phpize $ ./configure $ make all $ sudo make install
If your system has multiple version of PHP installed (e.g. macOS default and » XAMPP), note that each version of PHP has its own phpize command and php.ini file.
By default, the driver will use bundled versions of » libbson and » libmongoc and attempt to configure them on its own. If libbson and libmongoc are already installed as system libraries, you can instruct the driver to utilize them by specifying --with-libbson=yes --with--libmongoc=yes as arguments to configure.
For a complete list of configure options, run configure --help.
When using bundled versions of libbson and libmongoc, the driver will also attempt to select an SSL library according to the --with-mongodb-ssl option for configure. The default value is --with-mongodb-ssl=auto, which will search for Secure Transport (macOS only), OpenSSL, and LibreSSL, in that order. Additionally, you may specify openssl, libressl, or darwin to force selection of a particular library, respectively.
Note:
If the build process fails to find an SSL library, check that the development packages (e.g. libssl-dev) and » pkg-config are both installed.
When using Homebrew on macOS, it is common for a system to have multiple versions of OpenSSL installed. To ensure that the desired version of OpenSSL is selected, the PKG_CONFIG_PATH environment variable may be used to control the search path for pkg-config. If pkg-config is not used, configure also supports a --with-openssl-dir=DIR argument, which can be used to specify a manual search path (for OpenSSL only).
The final build step, make install, 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 for 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.
Finally, add the following line to your php.ini file:
extension=mongodb.so
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-mongodb.installation.manual.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.