http://pecl.php.net/package/mongo
https://github.com/mongodb/mongo-php-driver/tarball/master
1. 安装mongo的php插件
wget http://pecl.php.net/get/mongo-1.2.2.tgz //此php-driver包适用于php5.3;php5.4请选择1.2.12以上,1.2.12试用可以 tar xvf mongodb-mongo-php-driver-1.1.2-1-g5b2545e.tar.gz tar xvf mongo-1.2.2.tgz /usr/local/php/bin/phpize ./configure --enable-mongo=share --with-php-config=/usr/local/php/bin/php-config make && make install
最后输出
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/
2.编辑配置/etc/php.ini
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20060613/" extension = "mongo.so"
因为模块目录与mongo.so目录不一致,建立链接
ln -s /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/mongo.so /usr/local/php/lib/php/extensions/no-debug-zts-20060613/mongo.so
3.检查是否安装成功
重启php,运行php -m| grep mongo 可以看到mongo插件已经被启用。
运行 php --ri mongo,输出以下代表可用。
mongo MongoDB Support => enabled Version => 1.2.12 Directive => Local Value => Master Value mongo.allow_persistent => 1 => 1 mongo.default_host => localhost => localhost mongo.default_port => 27017 => 27017 mongo.chunk_size => 262144 => 262144 mongo.cmd => $ => $ mongo.utf8 => 1 => 1 mongo.native_long => 0 => 0 mongo.long_as_object => 0 => 0 mongo.allow_empty_keys => 0 => 0 mongo.no_id => 0 => 0 mongo.ping_interval => 5 => 5 mongo.is_master_interval => 60 => 60