First, install MongoDB from ports:

sudo port install mongodb  

Second:

sudo mkdir /opt/local/etc/mongodb  

and save what follows as
/opt/local/etc/mongodb/mongod.conf

# configuration file /opt/local/etc/mongodb/mongod.conf

# Store data alongside MongoDB instead of the default, /data/db/
dbpath = /opt/local/var/db/mongodb

# Only accept local connections
bind_ip = 127.0.0.1

# Running as daemon
fork = true

# Take log
logpath = /opt/local/var/log/mongodb/mongodb.log  
logappend = true

Third, append the following to ~/.profile:

alias mongostart="ulimit -n 2048 && sudo mongod -f /opt/local/etc/mongodb/mongod.conf"

mongostop_func () {  
  local mongopid=`less /opt/local/var/db/mongodb/mongod.lock`;
  if [[ $mongopid =~ [[:digit:]] ]]; then
      sudo kill -15 $mongopid;
      echo mongod process $mongopid terminated;
  else
      echo mongo process $mongopid not exist;
  fi
}

alias mongostop="mongostop_func"  

Bibliography: