MongoDB is an open source document-oriented database.
WebFaction servers less than Web300 or less than Dweb89 only support the 32-bit version of MongoDB. The 32-bit version of MongoDB is limited to storing approximately 2.5GB of data. For more information on this limitation, please see the MongoDB blog article “32 bit limitations.”
To install MongoDB:
Create an custom application to make a directory and receive a port assignment for your MongoDB installation.
- Log in to the control panel.
- Click Domains / websites ‣ Applications. The list of applications appears.
- Click the Add new application button. The Create a new application form appears.
- In the Name field, enter a name for the application.
- In the App Category menu, click to select Custom.
- In the App Type menu, click to select Custom app (listening on port).
- If applicable, in the Machine menu, select a web server.
- Click the Save button. The application is created and added to the list of applications.
- Make a note of the application’s port number. The application’s port number appears next to the application’s type. It is required in a later installation step.
Open an SSH session to your account.
Switch to the MongoDB application directory. Enter cd $HOME/webapps/application, where application is the name of the MongoDB application as it appears on the control panel, and press Enter.
Download the MongoDB Linux archive. Enter wget url, where url is the download URL for MongoDB, and press Enter.
See the MongoDB downloads page for download URLs. If you’re using a server less than Web300 or less than Dweb89, choose the Linux 32-bit download URL. If you’re using any other server, choose the Linux 64-bit download URL.
An archive, named mongodb-linux-architecture-version.tgz where architecture is x86_64 or i686 and version is the MongoDB version number, is created in the current directory.
Extract the contents of the archive. Enter tar -xzf mongodb-linux-architecture-version.tgz and press Enter. A new directory is created in the current directory that contains the MongoDB files.
Create a database data directory. Enter mkdir data and press Enter.
Start the MongoDB database. Enter $HOME/webapps/application/mongodb-linux-architecture-version/bin/mongod --auth --dbpath $HOME/webapps/application/data/ --port number, where number is the port number provided by the control panel, and press Enter.
Always start MongoDB with the --auth switch to prevent unauthorized users from tampering with your data.
Open a second SSH session to your account. Leave the first session with MongoDB running.
In the second session, connect to the database. Enter $HOME/webapps/application/mongodb-linux-architecture-version/bin/mongo localhost:port/admin and press Enter. An interactive prompt (>) appears.
Add an administrator user. Enter db.addUser("admin", "password"), where admin is the new administrator username of your choice and password is the new user’s password, and press Enter.
Authenticate as the administrator user. Enter db.auth("admin", "password") and press Enter. If authentication is successful, a 1 appears.
For more information about user authentication, see the MongoDB Authentication documentation.
Close the database connection. Enter exit and press Enter. You may also end the SSH session.
The database is configured and ready. You may start and stop the database as needed.
To start the database, run $HOME/webapps/application/mongodb-linux-architecture-version/bin/mongod --auth --dbpath $HOME/webapps/application/data/ --port number.
To stop MongoDB while it is running in the foreground, press Ctrl + C. For other ways to stop the database, see the MongoDB Stopping mongod documentation.