Setting up parse-server on Ubuntu

(Digital Ocean: How To Run Parse Server on Ubuntu 14.04)
(Digital Ocean: How To Migrate a Parse App to Parse Server on Ubuntu 14.04)
(GitHub: NodeSource Node.js and io.js Binary Distributions)

Before You Begin

  1. Check for updates
    sudo apt-get update && sudo apt-get upgrade

Install Node.js, Development Tools, other stuff, and parse-server

  1. Go to user’s home directory
    cd ~
  2. See NodeSource page for up-to-date installation instructions
    curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
  3. Install nodejs, build-essential and git
    sudo apt-get install -y nodejs build-essential git
  4. Install htop
    sudo apt-get install htop
  5. Install bcrypt
    sudo apt-get install bcrypt
  6. Install tmux to allow processes to run without ssh connection
    sudo apt install tmux
  7. Install parse-server and mongodb-runner (I haven’t figured out what the runner does)
    sudo npm install -g parse-server mongodb-runner

Setup Parse Cloud Code

  1. Go to user’s home directory
    cd ~
  2. Make a cloud directory
    mkdir -p ~/cloud
  3. Make a main.js file
    nano ~/cloud/main.js
  4. Paste
    Parse.Cloud.define('hello', function(req, res) {
      res.success('Hi');
    });
  5. Save and exit

Setup a new parse-server app

  1. Things you need
    • App name (long) ${newAppLong}
    • App name (short) ${newApp}
    • Password (no funny characters) ${password}
    • Parse port number ${port}
    • Parse appId ${appId}
    • Parse masterKey ${masterKey}
  2. Open port in ufw
    sudo ufw allow ${port}
  3. Add a new user to mongoDB
    mongo --port 27017
    use ${newApp}
    db.createUser({user: "${newApp}", pwd: "${password}", roles: [ { role: "dbOwner", db: "${newApp}"} ]})
    exit
  4. Restart MongoDB
    sudo service mongod restart
  5. Configure nginx for ${newApp} (parseapp) as per Setting up nginx on Ubuntu for parse-server
  6. Start parse-server on boot
    crontab -e
    If first run, select nano, 2
    At the bottom of the file add either:

    • for https://example.com/${newApp}/
      @reboot tmux new-session -s test -d parse-server --port ${port} --appId ${appId} --masterKey ${masterKey} --databaseURI mongodb://${newApp}:${password}@localhost:27017/${newApp} --cloud /home/parse/cloud/main.js --serverURL https://example.com/${newApp}/ --appName "${newAppLong}"
    • or for https://${newApp}.example.com/
      @reboot tmux new-session -s test -d parse-server --port ${port} --appId ${appId} --masterKey ${masterKey} --databaseURI mongodb://${newApp}:${password}@localhost:27017/${newApp} --cloud /home/${currentUser}/cloud/main.js --serverURL https://${newApp}.example.com/ --appName "${newAppLong}"

    Save & exit

  7. Open a new terminal window
  8. Check if npm and node are installed locally
    npm -v
    node -v
  9. If not, download and install fromhttps://nodejs.org/

  10. Install parse-dashboard locally
    sudo npm install -g parse-dashboard
  11. Run parse-dashboard locally
    parse-dashboard --appId ${appId} --masterKey ${masterKey} --serverURL https://example.com/${newApp}/ --appName "${newAppLong}"
    or
    parse-dashboard --appId ${appId} --masterKey ${masterKey} --serverURL https://${newApp}.example.com/ --appName "${newAppLong}"

Mini series

  1. Setting up a server at Linode
  2. Install Let’s Encrypt to Create SSL Certificates on Ubuntu
  3. Setting up MongoDB on Ubuntu
  4. Setting up nginx on Ubuntu for parse-server
  5. Setting up parse-server on Ubuntu

One Reply to “Setting up parse-server on Ubuntu”

Comments are closed.