- Download MongoDB for Mac OS
- Extract the contents of the
tgz
file to/usr/local/mongo
( or wherever ) - Create a new launch plist with the following content at
/Library/LaunchDaemons/com.mongo.db.plist
(take note that you will need to change the User Name value in the below plist):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.mongo.db</string>
<key>UserName</key>
<string>THE USER YOU WANT IT TO RUN AS</string>
<key>SessionCreate</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/usr/local/mongo/bin/mongod</string>
<string>--master</string>
<string>--logpath</string>
<string>/usr/local/mongo/log/mongo.log</string>
<string>--dbpath</string>
<string>/usr/local/mongo/data</string>
</array>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/usr/local/mongo/log/stdout.log</string>
<key>StandardErrorPath</key>
<string>/usr/local/mongo/log/error.log</string>
</dict>
</plist>
- Load the server via
sudo launchctl load /Library/LaunchDaemons/com.mongo.db.plist