MongoDB PHP extension
This tutorial shows you how to install MongoDB extension on Linux, window, Mac platform.
Install MongoDB PHP extension on Linux
Mounted on the terminal
You can execute the following command to install MongoDB PHP extension in linux driver
$ sudo pecl install mongo
Php installation using the pecl command must ensure that the network connection is available as well as root privileges.Installation Manual
If you want to compile the source code by the extended drive. You have to manually compile the source package, this is a good bug is included in the latest revised source package.
You can download the MongoDB PHP driver package on Github. Access github website and then search for "mongo php driver" (Download: https://github.com/mongodb/mongo-php-driver ), download the source package, and then execute the following command:
$ tar zxvf mongodb-mongodb-php-driver-<commit_id>.tar.gz $ cd mongodb-mongodb-php-driver-<commit_id> $ phpize $ ./configure $ sudo make install
If your php compiled yourself, the installation method is as follows (assuming the compiler in / usr / local / php directory):
$ tar zxvf mongodb-mongodb-php-driver-<commit_id>.tar.gz $ cd mongodb-mongodb-php-driver-<commit_id> $ /usr/local/php/bin/phpize $ ./configure --with-php-config=/usr/local/php/bin/php-config $ sudo make install
After executing the above command, you need to modify the php.ini file, add mongo configuration in the php.ini file, configuration is as follows:
Note: You need to specify the path extension_dir configuration items.
Install MongoDB PHP extension on the window
On Github has provided precompiled php mongodb window platform for driving binary packages (Download: https://s3.amazonaws.com/drivers.mongodb.org/php/index.html ), you can download your php the corresponding version, but you need to pay attention to the following questions:
- VC6 is running on Apache server
- 'Thread safe' (thread-safe) is running on Apache with the PHP module, if you run PHP in CGI mode, select a non-thread-safe mode ( 'non-thread safe').
- VC9 is running on the IIS server.
- After you need to download a binary package, extract the archive to add 'php_mongo.dll' file to your PHP extension directory (ext). ext directory is usually in the PHP installation directory ext directory.
Open the php configuration file php.ini add the following configuration:
Restart the server.
Phpinfo access through a browser, if the installation is successful, you will see the following types of information:
MAC install MongoDB PHP driver extensions
You can use the 'autoconf' install MongoDB PHP driver extensions.
You can use the 'Xcode' install MongoDB PHP driver extensions.
If you are using XAMPP, you can use the following command to install MongoDB PHP driver extensions:
sudo /Applications/XAMPP/xamppfiles/bin/pecl install mongo
If the above command in XMPP or MAMP does not work, you need to download on Github compatible precompiled packages.
Then add the 'extension = mongo.so' to your php.ini configuration file.