mongodb安装

  • 安装mongodb
        wget  http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.2.1.tgz
        tar zxvf mongodb-linux-x86_64-2.2.1.tgz
        mv mongodb-linux-x86_64-2.2.1 /usr/local/webserver/mongodb
        mkdir -p /usr/local/webserver/mongodb/data/mongodb_data
        cd /usr/local/webserver/mongodb/data
        mkdir mongodb
        cd /usr/local/webserver/mongodb
        touch logs
    
  • 安装php扩展mongo
    1. 下载扩展包
      wget http://pecl.php.net/get/mongo-1.3.0RC2.tgz
      
    2. 编译并安装
        tar zxvf mongo-1.3.0RC2.tgz
        cd mongo-1.3.0RC2
        /usr/local/webserver/php/bin/phpize
        ./configure --enable-mongo  --with-php-config=/usr/local/webserver/php/bin/php-config
        make && make install
      
    3. 安装成功的标志(扩展库存放路径)
      /usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/
      


    4. php.ini配置
      • 查找“extension_dir”,修改为如下代码:
             extension_dir='/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/'
        
      • 查找“extension”,任意地方添加如下代码:
           extension=mongo.so
        
  • 配置启动脚本

vim /etc/init.d/mongo

#!/bin/bash

mongod=/usr/local/webserver/mongodb/bin/mongod
mongo_path=/usr/local/webserver/mongodb/data/
MONGO_USER=mongod
MONGO_GROUP=mongod
#. "$SYSCONFIG" || true
start()
{
    echo -n $"Starting mongod: "
        $mongod --dbpath=${mongo_path}/mongodb_data/ --logpath=${mongo_path}/mongodb_logs.log --logappend --port=27017 --fork --source=127.0.0.1 --pidfilepath=/tmp/mong
        odb.p
        id

        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongod
}
stop()
{
  echo -n $"Stopping mongod: "
  #kill proc -p /www/data/mongo/mongod.lock -t30 -TERM $mongod
   kill `cat /tmp/mongodb.pid`
  RETVAL=$?
  echo
  [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/mongod /tmp/mongodb.pid
}
restart () {
 stop
 start
}
ulimit -n 12000
RETVAL=0
case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart|reload|force-reload)
    restart
    ;;
  condrestart)
    [ -f /var/lock/subsys/mongod ] && restart || :
    ;;
  status)
    status $mongod
    RETVAL=$?
    ;;
  *)
    echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
    RETVAL=1
esac
exit $RETVAL
  • 启动mongo
    server mongo start
    server mongo restart
    server mongo stop
    

內容目录

上一个主题

ecstore crontab配置

下一个主题

memcached安装

快速搜索

输入相关的模块,术语,类或者函数名称进行搜索