*安装php的mongo扩展
wget 'https://codeload.github.com/mongodb/mongo-php-driver/zip/master' -O /usr/local/src/mong_php.zip
cd /usr/local/src/
unzip mong_php.zip
cd mongo-php-driver-master/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
vi /usr/local/php/etc/php.ini //增加 extension = mongo.so
/usr/local/php/bin/php –m
重启apache,重新加载php
lnmp则重启php-fpm
*测试mongo扩展
vi /usr/local/apache2/htdocs/1.php //增加
<?php
// 连接到mongodb
$m = new MongoClient();
echo "Connection to database successfully";
// 选择一个数据库
$db = $m->mydb;
echo "Database mydb selected";
?>
curl localhost/1.php
参考 http://www.runoob.com/mongodb/mongodb-php.html