i found that php.ini file located in /etc/php.ini , when i open the file, it is empty. i have added the "extension=mongo.so" in the file, but still it didn't work. Can you tell me how to resolve it? every answer is fully appreciated. thanks before
インストール手順
MongoDB PHP ドライバは、ほぼすべてのシステムで動作します。 Windows、Mac OS X、Unix そして Linux。リトルエンディアンマシンおよびビッグエンディアンマシン。 32 ビットマシンおよび 64 ビットマシン。PHP 5.1、5.2 および 5.3。
この » PECL 拡張 モジュールは PHP にバンドルされていません。 このページでは、さまざまなシステムへのインストールに関するより詳細な情報とトラブルシューティングを扱います。
*NIX へのインストール
$ sudo pecl install mongo
CentOS あるいは Redhat を使っている場合は、Csoke Arpad が作った » RPM を使うことができます。
php.ini ファイルに次の行を追加します。
extension=mongo.so
インストール中に pecl が out of memory となる場合は、php.ini の memory_limit が 32M 以上あるかどうかを確認しましょう。
手動インストール
ドライバの開発者や最新のバグフィックス版に興味のあるかたは、 » Github にある最新のソースコードからドライバをコンパイルすることもできます。 Github に行き、"download" ボタンをクリックしましょう。そして以下のようにします。
$ tar zxvf mongodb-mongodb-php-driver-<commit_id>.tar.gz $ cd mongodb-mongodb-php-driver-<commit_id> $ phpize $ ./configure $ sudo make install
php.ini を次のように変更します。
-
extension_dir 変数が mongo.so の場所を指すようにします。 ビルド中に、PHP ドライバをどこにインストールするのかがこのように表示されます。
この場所が PHP の拡張モジュール用ディレクトリと一致するかどうかは、次のようにして確認します。Installing '/usr/lib/php/extensions/no-debug-zts-20060613/mongo.so'もし一致しない場合は、php.ini の extension_dir を変更するか、あるいは mongo.so を移動させます。$ php -i | grep extension_dir extension_dir => /usr/lib/php/extensions/no-debug-zts-20060613 => /usr/lib/php/extensions/no-debug-zts-20060613 -
PHP の起動時に拡張モジュールを読み込むために、次の行を追加します。
extension=mongo.so
OS X
autoconf が見つからない場合は、Xcode をインストールしなければなりません (これは、OS X のインストール DVD の中にあります。あるいは Apple のウェブサイトから無料でダウンロードすることもできます)。
XAMPP を使っている場合は、次のコマンドでドライバをコンパイルすることができます。
sudo /Applications/XAMPP/xamppfiles/bin/pecl install mongo
MAMP を使っている (あるいは XAMPP を使っているけれども上のコマンドがうまく動かない) 場合は、コンパイル済みのバイナリを » Github から取得します (最新版の "osx" の中から、PHP のバージョンにあわせたものをダウンロードします)。 アーカイブから mongo.so を取り出して MAMP あるいは XAMPP の拡張モジュール用ディレクトリに追加し、 php.ini に
extension=mongo.so
Gentoo
Gentoo には PHP ドライバのパッケージ dev-php5/mongo があり、 次のようにすればインストールできます。
$ sudo emerge -va dev-php5/mongo
PECL を使う場合は、libtool のバージョンが違うというエラーが出るかもしれません。 ソースからコンパイルするには、aclocal と autoconf を実行しなければなりません。
$ phpize && aclocal && autoconf && ./configure && make && make install
Red Hat
Fedora や CentOS も含みます。
これらのシステム上の Apache のデフォルト設定では リクエストがネットワーク接続できないようにしており、 データベースに接続しようとすると "Permission denied" というエラーが発生します。もしこの現象に遭遇したら、次のコマンドを実行しましょう。
$ /usr/sbin/setsebool -P httpd_can_network_connect 1
Windows へのインストール
リリースごとのコンパイル済みバイナリが » Github にあります。 バージョン、スレッドセーフ/非スレッドセーフ、VCのライブラリのさまざまな組み合わせに対応しています。 アーカイブを Unzip して、php_mongo.dll を PHP 拡張モジュールのディレクトリ (デフォルトは "ext") に置きましょう。
最新の (リリース前の) コードをコンパイルした Windows バイナリも、 コミットのたびに作られています。この zip には、php_mongo.dll が入った zip と version.txt が含まれています。version.txt は常に手元に置いてください。 疑問や問題が発生した場合に、それを使えば正確なバージョンを開発者に伝えることができます (バージョン番号は非常に長くて意味がなさそうな数値ですが、 開発者たちにとってはそれが重要な意味を持つのです!)。
最新のバグフィックス版を取得するは、 インストールしている PHP に対応したバイナリをダウンロードします。
そして、php.ini に次の行を追加します。
extension=php_mongo.dll
その他のインストール説明
PHP 用ドライバのインストールに関するすばらしいチュートリアルが、 多くのかたによって公開されています。
-
» PHP 5.3.1 with Xdebug, MongoDB and Lithium on Ubuntu 9.10 / Apache 2.2
Jon Adams によるすばらしい動画です。 Apache, PHP, Xdebug, MongoDB, そして Lithium のインストール手順をひとつひとつ説明しています。
-
» Installing MongoDB and the PHP driver on Ubuntu 9.04
Javier Aranda によるスペイン語の記事です (» 英語訳)。
-
» OS X: Installing MongoDB and the PHP Mongo Driver
Matt Butcher によるものです。
There is no php_mongo.dll for x64 PHP. PHP doesn't load pre-compiled version (error: "%1 is not a valid Win32 application")
In Windows running IIS the directory to instal is "C:\Program Files\PHP\ext". Than you have to install the apropriate MongoDriver version (in my case was mongo-1.1.4-php5.3vc9) and than Restart IIS.
The MongoDB Driver will be available.
I am using XAMPP 1.7.4 (32 bit) on Windows 7. Though it was mentioned that Apache uses a non-threadsafe version of DLL, when used, it was giving me the below error:
PHP Warning: PHP Startup: Unable to load dynamic library
Warning: PHP Startup: Unable to load dynamic library 'D:\xampp\php\ext\php_mongo.dll' - The specified module could not be found.
I had to use the thread-safe version (mongo-1.1.4.zip\mongo-1.1.4-php5.3vc6ts\php_mongo.dll) to get it working.
On windows installation check for VC compilator version inside phpinfo(), if you install incorrect one it wouldn't work.
I tried to run on Apache2 with VC6, and always get folowing error:
Fatal error: Class 'Mongo' not found
Until I look into phpinfo and found MSVC9, after that
I install VC9 dll files and it solve the problem.
If you're running IIS under Windows 7 and have PHP manager installed you'll also need to manually enable the extension. Start IIS Manager, select PHP Manager, under the section labeled PHP Extensions click on Enable or disable an extension, then enable the php_mongo.dll extension, and restart IIS.
I was only able to solve an xmapp install problem by accessing the cached version of this page - which was at the time hosted at mongo.
in the comments someone said
Setup on XAMPP
Install the Developer package for XAMPP
Make sure the the Apple Developer Tools are installed
!!!Edit your php.ini file with extension=mongo. For some reason, the build did not work until I did that.
if XAMPP install in your Application folder, run sudo /Applications/XAMPP/xamppfiles/bin/pecl install mongo
Restart XAMPP
which worked.
using the github packages it ended up being compiled with different versions of whatever and then threw an error in the log and wasnt included.
For Debian users: apt-get install php5-dev will install phpize for you.
