,ggg, ,ggg,_,ggg,                        ,ggg,
             ,dPYb,            dP""Y8dP""Y88P""Y8b                      dP""8I           8I
             IP'`Yb            Yb, `88'  `88'  `88                     dP   88           8I
             I8  8I             `"  88    88    88                    dP    88           8I                      gg
             I8  8'                 88    88    88                   ,8'    88           8I                      ""
 gg,gggg,    I8 dPgg,   gg,gggg,    88    88    88    ,ggggg,        d88888888     ,gggg,8I   ,ggg,,ggg,,ggg,    gg    ,ggg,,ggg,
 I8P"  "Yb   I8dP" "8I  I8P"  "Yb   88    88    88   dP"  "Y8       ,8"     88    dP"  "Y8I  ,8" "8P" "8P" "8,   88   ,8" "8P" "8,
 I8'    ,8i  I8P    I8  I8'    ,8i  88    88    88  i8'    ,8 dP   ,8P      Y8   i8'    ,8I  I8   8I   8I   8I   88   I8   8I   8I
,I8 _  ,d8' ,d8     I8,,I8 _  ,d8'  88    88    Y8,,d8,   ,d8 Yb,_,dP       `8b,,d8,   ,d8b,,dP   8I   8I   Yb,_,88,_,dP   8I   Yb,
PI8 YY88888P88P     `Y8PI8 YY88     88    88    `Y8P"Y8888P"   "Y8P"         `Y8P"Y8888P"`Y88P'   8I   8I   `Y88P""Y88P'   8I   `Y8
 I8                     I8
 I8                     I8
 I8                     I8
 I8                     I8
 I8                     I8
 I8                     I8

Simplified installation of MongoDB on Linux

Mongo database install

  • mkdir /data /data/db
  • cd /data
  • wget http://downloads.mongodb.org/linux/mongodb-linux-x86_64-latest.tgz
  • tar -xvzf mongodb-linux-x86_64-latest.tgz

    # Adjust the following two commands for the Mongo version extracted in the previous steps
    #
    To view the version of the extracted folder type ls (lowercase LS)
  • ln -s mongodb-linux-x86_64-1.4.2/bin/mongo mongo
  • ln -s mongodb-linux-x86_64-1.4.2/bin/mongod mongod

  • iptables -A INPUT -p tcp --dport 27017 -s 127.0.0.1 -j ACCEPT
  • iptables -A INPUT -p tcp --dport 27017 -j REJECT
  • iptables-save > /etc/iptables.rules
  • vi /etc/init.d/mongodb
    #!/bin/sh
    case "$1" in
    start)
    iptables-restore < /etc/iptables.rules > /dev/null
    /data/mongod --fork --quiet --logpath /var/log/mongodb.log --logappend > /dev/null
    exit 1;
    ;;
    stop)
    pkill mongod #pkill is not in all Linux versions, some may need to use killall or similar
    exit 1;
    ;;
    restart|force-reload)
    $0 stop $*
    sleep 1
    $0 start $*
    exit 1;
    ;;
    esac;
  • chmod 755 /etc/init.d/mongodb
  • /etc/init.d/mongodb start
  • update-rc.d mongodb defaults 99

Add the Mongo extension to PHP

  • pecl install mongo
  • vi /etc/php5/apache2/php.ini
  • and then add to it: extension=mongo.so
  • Restart your web server (Apache, nginx, etc.) for the change to take effect
Powered by Avinu