Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 16354 программиста и 1794 робота. Сейчас ищут 2034 программиста ...
Приступая к работе

Установка

Внимание

This extension is deprecated. Instead, the MongoDB extension should be used.

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.3 through 5.6 (versions prior to 1.6 also support PHP 5.2).

Это расширение » PECL не поставляется вместе с PHP.

Manual Installation

For driver developers and people interested in the latest bugfixes, you can compile the driver from the latest source code on » Github. Go to Github and click the "download" button. Then run:

$ tar zxvf mongodb-mongodb-php-driver-<commit_id>.tar.gz
$ cd mongodb-mongodb-php-driver-<commit_id>
$ phpize
$ ./configure
$ make all
$ sudo make install

Make the following changes to php.ini:

  • Make sure the extension_dir variable is pointing to the directory containing mongo.so. The build will display where it is installing the PHP driver with output that looks something like:

    Installing '/usr/lib/php/extensions/no-debug-non-zts-20060613/mongo.so'
    Make sure that it is the same as the PHP extension directory by running:
    $ 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
    If it's not, change the extension_dir in php.ini or move mongo.so.

  • To load the extension on PHP startup, add a line:

    extension=mongo.so

Installing on *NIX

Run:

$ sudo pecl install mongo

If you are using CentOS or Redhat, you may wish to install from an » RPM.

Add the following line to your php.ini file:

extension=mongo.so

If pecl runs out of memory while installing, make sure memory_limit in php.ini is set to at least 128MB.

Installing on Windows

Precompiled binaries for each release are available from » PECL 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).

Add the following line to your php.ini file:

extension=php_mongo.dll

Замечание: Additional DLL dependencies for Windows Users

Для работы этого расширения системной переменной Windows PATHдолжны быть доступны DLL-файлы. Чтобы узнать как этого достичь, обратитесь к разделу FAQ "Как добавить мою директорию с PHP в переменную Windows PATH". Хотя копирование DLL-файлов из директории PHP в системную папку Windows также решает проблему (потому что системная директория по умолчанию находится в переменной PATH), это не рекомендуется. Этому расширению требуются следующие файлы в переменной PATH: libsasl.dll

OS X

In most cases installing from pecl is the easiest way:

$ sudo pecl install mongo

If you are using » Homebrew, the PHP tap includes formulae for the driver. For example, you might install the driver for PHP 5.6 using the following command:

$ brew install php56-mongo

If you are using » XAMPP, note that it has its own pecl binary and php.ini configuration. You should be able to install the driver with the following command:

$ sudo /Applications/XAMPP/xamppfiles/bin/pecl install mongo

Замечание: Xcode dependency for compiling on OS X

Compiling the driver on OS X will require Xcode developer tools, which may be installed with xcode-select --install. If that command is not available, you may first need to install the » Command Line Tools package.

Gentoo

Gentoo has a package for the PHP PECL driver called dev-php/pecl-mongo, which can be installed with:

$ sudo emerge -va dev-php/pecl-mongo

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.

$ phpize
$ aclocal 
$ autoconf 
$ ./configure
$ make
$ sudo make install

Red Hat

This includes Fedora and CentOS.

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:

$ /usr/sbin/setsebool -P httpd_can_network_connect 1
Then restart Apache. (This issue has also occurred with SELinux.)

Third-Party Installation Instructions

A number of people have created excellent tutorials on installing the PHP driver.



Вернуться к: Установка и настройка

© 2024 «PHP.RU — Сообщество PHP-Программистов»
Главная | Форум | Реклама на сайте | Контакты VIP Сувениры
Разработка компании ODware