php中增加mongodb支持

网上使用云数据库已经火了很长一段时间了,今天我也试试看这个功能。但是php并不自带mongodb模块,只能从github下载了编译安装模块。
(下载地址:https://github.com/mongodb/mongo-php-driver/archive/master.zip),下载该源码包,然后执行以下命令:
$ unzip master
$ cd mongo-php-driver-master
$ phpize
$ ./configure
$ make && make install
如果你的php是自己编译的,则安装方法如下(假设是编译在/usr/local/php目录中):
$ unzip master
$ cd mongo-php-driver-master
$ /usr/local/php/bin/phpize
$ ./configure –enable-mongo=share –with-php-config=/usr/local/php/bin/php-config
$ make && make install
最后出现的提示Build complete.Don’t forget to run ‘make test’.
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
说明安装成功 接下来配置php.ini
编辑php.ini 加入
extension=mongo.so

可以在phpinfo里面看到mongo就大功告成了。

Leave a Reply

Your email address will not be published. Required fields are marked *

*