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. 建立mongo索引(mongo index)
          mongo
          use ecos
          db.defalut.ensureIndex({key:1})
      
    5. php.ini配置
      • 查找“extension_dir”,修改为如下代码:
               extension_dir='/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/'
        
      • 查找“extension”,任意地方添加如下代码:
              extension=mongo.so
        
  • 配置启动脚本

注意:
在启动前,请确保以下两个目录存在:
/usr/local/webserver/mongodb/data/mongodb_data/
/var/lock/subsys/

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/mongodb.pid
    
            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
    service mongo start
    service mongo restart
    service mongo stop
    

內容目录

上一个主题

Ecstore伪静态配置

下一个主题

Memcached安装

快速搜索

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