CenterOS6.5(Minimal) 搭建MongoDB

安装基础库请参考这里

MongoDB(2.6.3)

下载安装

  1. wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.3.tgz -P /usr/local/app/sources/
  2. cd /usr/local/app/sources/
  3. tar -xf mongodb-linux-x86_64-2.6.3.tgz
  4. mv mongodb-linux-x86_64-2.6.3 /usr/local/app/mongodb/
  5. mkdir -p /usr/local/app/mongodb/conf
  6. mkdir -p /usr/local/app/mongodb/data
  7. mkdir -p /usr/local/app/mongodb/log
  8. 在conf目录加上mongodb.conf,内容如下:
dbpath=/usr/local/app/mongodb/data/
logpath=/usr/local/app/mongodb/log/mongodb.log 
fork = true
logappend = true

安装php扩展phpMongo(1.6.14)

  1. wget http://pecl.php.net/get/mongo-1.6.14.tgz -P /usr/local/app/sources/
  2. cd /usr/local/app/sources/
  3. tar mongo-1.6.14.tgz
  4. cd mongo-1.6.14
  5. /usr/local/app/php/bin/phpize
  6. ./configure --with-php-config=/usr/local/app/php/bin/php-config
  7. make
  8. make install
  9. 修改php.ini加入Mongodb扩展 vi /usr/local/app/php/lib/php.ini 加入
[mongodb]
extension = mongo.so
  1. 重启php
  2. 启动mongodb /usr/local/app/mongodb/bin/mongod --config /usr/local/app/mongodb/conf/mongodb.conf --nojournal &
  3. 修改/home/www/app/index.php 加入如下代码测试
var_dump(new MongoClient());
  1. 打开浏览器测试

你可能感兴趣的:(Linux)