<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Installation</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mongo.requirements.html">Requirements</a></div> <div class="next" style="text-align: right; float: right;"><a href="mongo.configuration.html">Runtime Configuration</a></div> <div class="up"><a href="mongo.setup.html">Installing/Configuring</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="mongo.installation" class="section"> <h2 class="title">Installation</h2> <p class="para"> The MongoDB PHP driver should work on nearly any system: Windows, Mac OS X, Unix, and Linux; little- and big-endian machines; 32- and 64-bit machines; PHP 5.2, 5.3, 5.4 and 5.5. </p> <p class="para"> This <a href="http://pecl.php.net/" class="link external">» PECL</a> extension is not bundled with PHP. </p> <ul class="simplelist"> <li class="member"> <a href="mongo.installation.html#mongo.installation.manual" class="xref">Manual Installation</a> </li> <li class="member"> <a href="mongo.installation.html#mongo.installation.nix" class="xref">Installing on *NIX</a> </li> <li class="member"> <a href="mongo.installation.html#mongo.installation.windows" class="xref">Installing on Windows</a> </li> <li class="member"> <a href="mongo.installation.html#mongo.installation.osx" class="xref">OS X</a> </li> <li class="member"> <a href="mongo.installation.html#mongo.installation.gentoo" class="xref">Gentoo</a> </li> <li class="member"> <a href="mongo.installation.html#mongo.installation.fedora" class="xref">Red Hat</a> </li> <li class="member"> <a href="mongo.installation.html#mongo.installation.thirdparty" class="xref">Third-Party Installation Instructions</a> </li> </ul> <div class="section" id="mongo.installation.manual"> <h2 class="title">Manual Installation</h2> <p class="para">For driver developers and people interested in the latest bugfixes, you can compile the driver from the latest source code on <a href="http://github.com/mongodb/mongo-php-driver" class="link external">» Github</a>. Go to Github and click the "download" button. Then run: <div class="example-contents"> <div class="cdata"><pre> $ tar zxvf mongodb-mongodb-php-driver-<commit_id>.tar.gz $ cd mongodb-mongodb-php-driver-<commit_id> $ phpize $ ./configure $ make all $ sudo make install </pre></div> </div> </p> <p class="para"> Make the following changes to php.ini: </p> <ul class="itemizedlist"> <li class="listitem"> <p class="para"> Make sure the <em class="emphasis">extension_dir</em> variable is pointing to the directory containing <em class="emphasis">mongo.so</em>. The build will display where it is installing the PHP driver with output that looks something like: <div class="example-contents"> <div class="cdata"><pre> Installing '/usr/lib/php/extensions/no-debug-non-zts-20060613/mongo.so' </pre></div> </div> Make sure that it is the same as the PHP extension directory by runnning: <div class="example-contents"> <div class="cdata"><pre> $ php -i | grep extension_dir extension_dir => /usr/lib/php/extensions/no-debug-non-zts-20060613 => /usr/lib/php/extensions/no-debug-non-zts-20060613 </pre></div> </div> If it's not, change the <em class="emphasis">extension_dir</em> in php.ini or move <em class="emphasis">mongo.so</em>. </p> </li> <li class="listitem"> <p class="para"> To load the extension on PHP startup, add a line: <div class="example-contents"> <div class="cdata"><pre> extension=mongo.so </pre></div> </div> </p> </li> </ul> <div class="section" id="mongo.installation.nix"> <h2 class="title">Installing on *NIX</h2> <p class="para"> Run: <div class="example-contents"> <div class="cdata"><pre> $ sudo pecl install mongo </pre></div> </div> </p> <p class="para"> If you are using CentOS or Redhat, you may wish to install from an <a href="http://downloads-distro.mongodb.org/repo/redhat/os/" class="link external">» RPM</a>. </p> <p class="para"> Add the following line to your php.ini file: <div class="example-contents"> <div class="cdata"><pre> extension=mongo.so </pre></div> </div> </p> <p class="para"> If pecl runs out of memory while installing, make sure memory_limit in php.ini is set to at least 128MB. </p> </div> <div class="section" id="mongo.installation.windows"> <h2 class="title">Installing on Windows</h2> <p class="para"> Precompiled binaries for each release are available from <a href="https://s3.amazonaws.com/drivers.mongodb.org/php/index.html" class="link external">» S3</a> for a variety of combinations of versions, thread safety, and VC libraries. Unzip the archive and put php_mongo.dll in your PHP extension directory ("ext" by default). </p> <p class="para"> Add the following line to your php.ini file: <div class="example-contents"> <div class="cdata"><pre> extension=php_mongo.dll </pre></div> </div> </p> </div> <div class="section" id="mongo.installation.osx"> <h2 class="title">OS X</h2> <p class="para"> If your system is unable to find autoconf, you'll need to install Xcode (available on your installation DVD or as a free download from the Apple website). </p> <p class="para"> In most cases installing from pecl is the easiest way: <div class="example-contents"> <div class="shellcode"><pre class="shellcode">$ sudo pecl install mongo</pre> </div> </div> </p> <p class="para"> If you are using XAMPP, you may be able to compile the driver with the following command: <div class="example-contents"> <div class="cdata"><pre> sudo /Applications/XAMPP/xamppfiles/bin/pecl install mongo </pre></div> </div> </p> </div> <div class="section" id="mongo.installation.gentoo"> <h2 class="title">Gentoo</h2> <p class="para"> Gentoo has a package for the PHP driver called dev-php5/mongo, which can be installed with: </p> <div class="example-contents"> <div class="cdata"><pre> $ sudo emerge -va dev-php5/mongo </pre></div> </div> <p class="para"> If you use PECL, you may get an error that libtool is the wrong version. Compiling from source you'll need to run aclocal and autoconf. </p> <div class="example-contents"> <div class="cdata"><pre> $ phpize $ aclocal $ autoconf $ ./configure $ make $ sudo make install </pre></div> </div> </div> <div class="section" id="mongo.installation.fedora"> <h2 class="title">Red Hat</h2> <p class="para"> This includes Fedora and CentOS. </p> <p class="para"> The default Apache settings on these systems do not let requests make network connections, meaning that the driver will get "Permission denied" errors when it tries to connect to the database. If you run into this, try running: <div class="example-contents"> <div class="cdata"><pre> $ /usr/sbin/setsebool -P httpd_can_network_connect 1 </pre></div> </div> Then restart Apache. (This issue has also occurred with SELinux.) </p> </div> </div> <div class="section" id="mongo.installation.thirdparty"> <h2 class="title">Third-Party Installation Instructions</h2> <p class="para"> A number of people have created excellent tutorials on installing the PHP driver. </p> <ul class="itemizedlist"> <li class="listitem"> <p class="para"> <a href="http://www.vimeo.com/8005503" class="link external">» PHP 5.3.1 with Xdebug, MongoDB and Lithium on Ubuntu 9.10 / Apache 2.2 </a> </p> <p class="para">An excellent video that takes you step-by-step through installing Apache, PHP, Xdebug, MongoDB, and Lithium by Jon Adams. </p> </li> <li class="listitem"> <p class="para"> <a href="http://javierav.com/2009-10-instalando-mongodb-driver-php-en-ubuntu-9-04.html" class="link external">» Installing MongoDB and the PHP driver on Ubuntu 9.04 </a> </p> <p class="para"> Spanish article by Javier Aranda (<a href="http://translate.google.com/translate?js=n&prev=_t&hl=en&ie=UTF-8&layout=2&eotf=1&sl=auto&tl=en&u=http://javierav.com/2009-10-instalando-mongodb-driver-php-en-ubuntu-9-04.html" class="link external">» English translation</a>). </p> </li> <li class="listitem"> <p class="para"> <a href="http://technosophos.com/content/os-x-installing-mongodb-and-php-mongo-driver" class="link external">» OS X: Installing MongoDB and the PHP Mongo Driver </a> </p> <p class="para"> By Matt Butcher. </p> </li> </ul> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mongo.requirements.html">Requirements</a></div> <div class="next" style="text-align: right; float: right;"><a href="mongo.configuration.html">Runtime Configuration</a></div> <div class="up"><a href="mongo.setup.html">Installing/Configuring</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>