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
wget http://pecl.php.net/get/mongo-1.3.0RC2.tgz
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
/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/
mongo use ecos db.defalut.ensureIndex({key:1})
extension_dir='/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/'
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
service mongo start service mongo restart service mongo stop