## Configure the Database 

Consider the following basic configuration which uses the YAML format : 

processManagement: fork: true net: bindIp: 127.0.0.1 port: 27017 storage: dbPath: /srv/mongodb systemLog: destination: file path: "/var/log/mongodb/mongod.log" logAppend: true storage: journal: enabled: true 

Or, if using the older .ini configuration file format: 

fork = true bind_ip = 127.0.0.1 port = 27017 quiet = true dbpath = /srv/mongodb logpath = /var/log/mongodb/mongod.log logappend = true journal = true 

For most standalone servers, this is a sufficient base configuration. It makes several assumptions, but consider the following explanation: 

• fork is true , which enables a daemon mode for mongod , which detaches (i.e. “forks”) the MongoDB from the current session and allows you to run the database as a conventional server. 

• bindIp is 127.0.0.1 , which forces the server to only listen for requests on the localhost IP. Only bind to secure interfaces that the application-level systems can access with access control provided by system network filtering (i.e. “ firewall ”). 

New in version 2.6: mongod installed from official .deb (page 19) and .rpm (page 7) packages have the bind_ip configuration set to 127.0.0.1 by default. 

• port is 27017 , which is the default MongoDB port for database instances. MongoDB can bind to any port. You can also filter access based on port using network filtering tools. 

Note: UNIX-like systems require superuser privileges to attach processes to ports lower than 1024. 

• quiet is true . This disables all but the most critical entries in output/log file, and is not recommended for production systems. If you do set this option, you can use setParameter to modify this setting during run time. 

• dbPath is /srv/mongodb , which specifies where MongoDB will store its data files. /srv/mongodb and /var/lib/mongodb are popular locations. The user account that mongod runs under will need read and write access to this directory. 

• systemLog.path is /var/log/mongodb/mongod.log which is where mongod will write its output. If you do not set this value, mongod writes all output to standard output (e.g. stdout .) 

