Centos linux环境安装MongoDB、php的MongoDB扩展支持

 YUM方式安装MongoDB rpm二进制包

人懒,直接rpm二进制包安装

[root@a5139 ~]# touch /etc/yum.repos.d/10gen.repo
[root@a5139 ~]# vi /etc/yum.repos.d/10gen.repo

#如果是64位写入
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0
enabled=1

#如果是32位写入
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686
gpgcheck=0
enabled=1

yum install mongo-10gen mongo-10gen-server

PHP MongoDB 扩展安装

[root@a5139 ~]# wget http://pecl.php.net/get/mongo-1.3.4.tgz

[root@a5139 ~]# tar zxvf mongo-1.3.4.tgz

[root@a5139 ~]# cd mongo-1.3.4

[root@a5139 mongo-1.3.4]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519

[root@a5139 mongo-1.3.4]# ./configure –with-php-config=/usr/local/php/bin/php-config

[root@a5139 mongo-1.3.4]# make && make install

Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/

[root@a5139 mongo-1.3.4]# ls /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/
memcache.so mongo.so pdo_mysql.so

[root@a5139 mongo-1.3.4]# vi /usr/local/php/etc/php.ini

#加入

extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/”
#extension = “memcache.so”
#extension = “pdo_mysql.so”
extension = “mongo.so”

[root@a5139 mongo-1.3.4]# /etc/init.d/php-fpm restart
Shutting down php_fpm . done
Starting php_fpm done

#探针查看已经支持mongodb鸟!

 

参考文献:
1、Install MongoDB on Red Hat Enterprise, CentOS, or Fedora Linux
2PHP Language Center
打赏

发表评论

电子邮件地址不会被公开。 必填项已用*标注