php-doc-en/reference/mongo/configure.xml
Christoph Michael Becker 9cc4767b2d What's in a name?
The Macintosh operating systems changed their name a few times since
version 10. We follow suite, and use the proper name whenever we refer
to a certain version, and use “macOS” as generic term, since “Mac OS X”
and “OS X” versions are already unsupported, or loose support at the end
of this year.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@345139 c90b9560-bf6c-de11-be94-00142212c4b1
2018-06-15 11:50:40 +00:00

317 lines
8.1 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<section xml:id="mongo.installation" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.install;
<warning>
&mongo.deprecated.note;
</warning>
<para>
The MongoDB PHP driver should work on nearly any system: Windows, macOS,
Unix, and Linux; little- and big-endian machines; 32- and 64-bit machines; PHP
5.3 through 5.6 (versions prior to 1.6 also support PHP 5.2).
</para>
<para>
&pecl.moved;
</para>
<simplelist>
<member>
<xref linkend="mongo.installation.manual" />
</member>
<member>
<xref linkend="mongo.installation.nix" />
</member>
<member>
<xref linkend="mongo.installation.windows" />
</member>
<member>
<xref linkend="mongo.installation.osx" />
</member>
<member>
<xref linkend="mongo.installation.gentoo" />
</member>
<member>
<xref linkend="mongo.installation.fedora" />
</member>
<member>
<xref linkend="mongo.installation.thirdparty" />
</member>
</simplelist>
<section xml:id="mongo.installation.manual">
<title>Manual Installation</title>
<para>For driver developers and people interested in the latest bugfixes, you
can compile the driver from the latest source code on
<link xlink:href="&url.mongodb.github;">Github</link>.
Go to Github and click the "download" button. Then run:
<programlisting role="shell">
<![CDATA[
$ tar zxvf mongodb-mongodb-php-driver-<commit_id>.tar.gz
$ cd mongodb-mongodb-php-driver-<commit_id>
$ phpize
$ ./configure
$ make all
$ sudo make install
]]>
</programlisting>
</para>
<para>
Make the following changes to php.ini:
</para>
<itemizedlist>
<listitem>
<para>
Make sure the <emphasis>extension_dir</emphasis> variable is pointing to
the directory containing <emphasis>mongo.so</emphasis>. The build will display where
it is installing the PHP driver with output that looks something like:
<programlisting role="txt">
<![CDATA[
Installing '/usr/lib/php/extensions/no-debug-non-zts-20060613/mongo.so'
]]>
</programlisting>
Make sure that it is the same as the PHP extension directory by running:
<programlisting role="shell">
<![CDATA[
$ 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
]]>
</programlisting>
If it's not, change the <emphasis>extension_dir</emphasis> in php.ini or
move <emphasis>mongo.so</emphasis>.
</para>
</listitem>
<listitem>
<para>
To load the extension on PHP startup, add a line:
<programlisting role="ini">
<![CDATA[
extension=mongo.so
]]>
</programlisting>
</para>
</listitem>
</itemizedlist>
</section>
<section xml:id="mongo.installation.nix">
<title>Installing on *NIX</title>
<para>
Run:
<programlisting role="shell">
<![CDATA[
$ sudo pecl install mongo
]]>
</programlisting>
</para>
<para>
Add the following line to your php.ini file:
<programlisting role="ini">
<![CDATA[
extension=mongo.so
]]>
</programlisting>
</para>
<para>
If pecl runs out of memory while installing, make sure memory_limit in
php.ini is set to at least 128MB.
</para>
</section>
<section xml:id="mongo.installation.windows">
<title>Installing on Windows</title>
<para>
Precompiled binaries for each release are available from
<link xlink:href="&url.pecl.package;mongo">PECL</link> 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).
</para>
<para>
Add the following line to your php.ini file:
<programlisting role="ini">
<![CDATA[
extension=php_mongo.dll
]]>
</programlisting>
</para>
<note>
<title>Additional DLL dependencies for Windows Users</title>
<para>
&ext.windows.path.dll;
<filename>libsasl.dll</filename>
</para>
</note>
</section>
<section xml:id="mongo.installation.osx">
<title>macOS</title>
<para>
In most cases installing from PECL is the easiest way:
<programlisting role="shell">
<![CDATA[
$ sudo pecl install mongo
]]>
</programlisting>
</para>
<note>
<simpara>
<link xlink:href="https://brew.sh/2018/01/19/homebrew-1.5.0/">Homebrew 1.5.0</link>
deprecated the <link xlink:href="&url.mac.homebrew;">Homebrew/php tap</link>
and removed formulae for PHP extensions. Going forward, macOS users should
install the driver with PECL. Community forks of the
<link xlink:href="&url.mac.homebrew;">Homebrew/php tap</link> may still
contain formale for installing the driver on various PHP versions.
</simpara>
</note>
<para>
If you are using <link xlink:href="&url.xampp;">XAMPP</link>, note that it
has its own pecl binary and php.ini configuration. You should be able to
install the driver with the following command:
<programlisting role="shell">
<![CDATA[
$ sudo /Applications/XAMPP/xamppfiles/bin/pecl install mongo
]]>
</programlisting>
</para>
<note>
<title>Xcode dependency for compiling on macOS</title>
<para>
Compiling the driver on macOS will require Xcode developer tools, which may
be installed with <code>xcode-select --install</code>. If that command is
not available, you may first need to install the
<link xlink:href="&url.apple.clt;">Command Line Tools</link> package.
</para>
</note>
</section>
<section xml:id="mongo.installation.gentoo">
<title>Gentoo</title>
<para>
Gentoo has a package for the PHP PECL driver called dev-php/pecl-mongo, which can be
installed with:
</para>
<programlisting role="shell">
<![CDATA[
$ sudo emerge -va dev-php/pecl-mongo
]]>
</programlisting>
<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.
</para>
<programlisting role="shell">
<![CDATA[
$ phpize
$ aclocal
$ autoconf
$ ./configure
$ make
$ sudo make install
]]>
</programlisting>
</section>
<section xml:id="mongo.installation.fedora">
<title>Red Hat</title>
<para>
This includes Fedora and CentOS.
</para>
<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:
<programlisting role="shell">
<![CDATA[
$ /usr/sbin/setsebool -P httpd_can_network_connect 1
]]>
</programlisting>
Then restart Apache. (This issue has also occurred with SELinux.)
</para>
</section>
<section xml:id="mongo.installation.thirdparty">
<title>Third-Party Installation Instructions</title>
<para>
A number of people have created excellent tutorials on installing the PHP
driver.
</para>
<itemizedlist>
<listitem>
<para>
<link xlink:href="&url.mongodb.install.osx.homebrew;">
(Re)installing PHP on macOS
</link>
</para>
<para>
This article by Justin Hileman details the process of installing PHP and
additional extensions with Homebrew on macOS. This complements the earlier
instructions on this page for installing the driver with Homebrew.
</para>
</listitem>
<listitem>
<para>
<link xlink:href="&url.mongodb.install.ubuntu.9.10.video;">
PHP 5.3.1 with Xdebug, MongoDB and Lithium on Ubuntu 9.10 / Apache 2.2
</link>
</para>
<para>This screencast by Jon Adams demonstrates how to quickly get up and
running with PHP 5.3.1, Xdebug, and MongoDB on Ubuntu 9.10 with Apache.
</para>
</listitem>
</itemizedlist>
</section>
</section>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->