Search code examples
javascriptmongodbubuntuamazon-web-servicesdeployd

Finding MongoDB details after hosting on Ubuntu


I'm completely new to setting up servers, MongoDB, and still a little new to Javascript.

I'm trying to upload a Deployd server onto an online server. There is limited information on this, so at the moment, I set up a simple AWS Ubuntu server by doing the following tutorials:

http://zenborgium.blogspot.com/2012/12/how-to-setup-deployd-on-ubuntu-server.html

http://terraltech.com/how-to-setup-deployd-on-ubuntu-server/

However, I'm stuck at creating the production.js. There's a guide on it here. I'm specifically stuck at this line of code:

var server = deployd({
  port: process.env.PORT || 5000,
  env: 'production',
  db: {
    host: 'my.production.mongo.host',
    port: 27105,
    name: 'my-db',
    credentials: {
      username: 'username',
      password: 'password'
    }
  }
});

server.listen();

Where do I find the host, port, name, and credentials that I should use from MongoDB? The tutorials say I need to use my own data, but I don't know where or how to find them.


Solution

  • First of all, you have to have MongoDB installed. I haven't used Deployd myself, but I will give you some information regarding the config file.

    • If you are running Mongo on the same ubuntu server as your application, you can use localhost to connect.
    • Default Mongo install runs on port 27017, in other words localhost:27017.
    • The 'name' parameter is just a name you give your database. So here you can put whatever you want, ex my-db.
    • With a clean Mongo install, you don't need any credentials. You have to set that up yourself if you want. I suppose leaving them out of the config file is ok, if not needed.

    Your config file should therefor look something like this:

    var server = deployd({
      port: process.env.PORT || 5000,
      env: 'production',
      db: {
        host: 'localhost',
        port: 27017,
        name: 'my-db'
      }
    });
    


    update
    I had a quick look at the tutorial you linked to. In one of the tutorials they created a user for mongodb. If you followed this step, you need to put that login information into you connect-object under credentials.

    update 2
    To get information about your mongodb install, check this SO post