php安装mongo扩展和mongodb扩展 – 21运维
通知: .-...

php安装mongo扩展和mongodb扩展

mongodb 21运维 1476浏览

mongo扩展主要是针对php 5.x的,而且以后不提供更新维护;后续一般都用mongodb扩展,当然,要根据实际生产环境来确定。还是要看需求。

方法1:git下载安装包安装mongodb扩展

cd /usr/local/src/
 git clone https://github.com/mongodb/mongo-php-driver
 cd mongo-php-driver
 git submodule update --init
 /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 = mongodb.so
 /usr/local/php/bin/php -m

方法2:pecl下载扩展包安装mongodb扩展
大家还可以到pecl官网上下载mongodb的扩展源码包

 cd /usr/local/src/
 wget https://pecl.php.net/get/mongodb-1.3.0.tgz 
 tar zxvf mongodb-1.3.0.tgz
 cd mongodb-1.3.0
 /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 = mongodb.so
 /usr/local/php/bin/php -m

方法3:pecl下载安装包安装mongo扩展
到pecl官网上下载mongo的扩展源码包

 cd /usr/local/src/
 wget https://pecl.php.net/get/mongo-1.6.16.tgz 
 tar zxvf mongodb-1.6.16.tgz
 cd mongodb-1.6.16
 /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

转载请注明:21运维 » php安装mongo扩展和mongodb扩展