To access MongoDB from PHP you need:
sudo pecl install mongo
Open your php.ini file and add to it:
It is recommended to add this to the section with the other “extensions,” but it will work from anywhere within the php.ini file.
Restart your web server (Apache, nginx, etc.) for the change to take effect.
See the installation docs for configuration information and OS-specific installation instructions.
pecl requires that pear be installed. For those using apt-get, you may need to run the following:
sudo apt-get install php5-dev php5-cli php-pear
Download the correct driver for your environment from <https://s3.amazonaws.com/drivers.mongodb.org/php/index.html>. Thread safe builds are used when running PHP as an Apache module (typical installation); non-thread safe builds, which include “nts” in the filename, are used for CGI.
Unzip and add the appropriate php_mongo.dll file to your PHP extensions directory (usually the ext folder in your PHP installation).
Add to your php.ini:
Restart your web server (Apache, IIS, etc.) for the change to take effect.
For more information, see the Windows section of the installation docs.