wget 'https://pecl.php.net/get/mongo-1.6.9.tgz' -O /usr/local/src/mong_php.zip
cd /usr/local/src/
tar zxvf mong_php.zip
cd /usr/local/src/mongo-1.6.9
/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
测试
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