Topic: Howto: Install mongoDB

1) Update ports collection
2) Install mongoDB from ports:

# cd /usr/ports/databases/mongodb/
# make install clean

3) Add startup settings to /etc/rc.conf:

mongod_enable="YES"
mongod_config="/usr/local/etc/mongodb.conf"
mongod_dbpath="/var/db/mongodb"

4) Add settings to /usr/local/etc/mongodb.conf:

master = true
nohttpinterface = true

5) Run mongod daemon:

# service start mongod

Tip 1: If you get following message:

Starting mongod.
su: unknown login: mongodb
/usr/local/etc/rc.d/mongod: WARNING: failed to start mongod

You should to update master.passwd file with command:

# pwd_mkdb -p /etc/master.passwd

And then try to start mongod again.

Tip 2: If you want to use mongoDB with php, don't forget to install pecl mongo extension:

# cd /usr/ports/databases/pecl-mongo
# make install clean

And then add following strings to /usr/local/etc/php.ini:

[mongo]
mongo.default_host="localhost"
mongo.default_port=27017
mongo.auto_reconnect=1
mongo.allow_persistent=1
mongo.chunk_size=262144
mongo.cmd="$"
mongo.utf8=1