Parse is a mobile backend as a service platform, owned by Facebook since 2013. In January of 2016, Parse announced that its hosted services would shut down in January of 2017. So if you are Parse.com user, you will have to move all your services to own servers. This tutorial will help you for install Parse server on Ubuntu 18.04 & 16.04 LTS operating system.

Advertisement

Step 1 – Install Node.js

First, you need to node.js ppa in our system provide by the nodejs official website. We also need to install python-software-properties package if not installed already.

sudo apt-get install build-essential git python-software-properties
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -

After adding required PPA file. Let’s install Nodejs package. NPM will also be installed with node.js. This command will also install many other dependent packages on your system.

sudo apt-get install nodejs

Step 2 – Install MongoDB Server

You also need to MongoDB database server on your system. Use following set of commands to install the latest version of MongoDB server.

Adding MongoDB PPA to your system.

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb.list

Now update apt cache and install MongoDB database server.

sudo apt-get update
sudo apt-get install mongodb-org

Step 3 – Download and Setup Parse Server

Now download example Parse server files provided by the Parse community developers.

cd /opt
git clone https://github.com/parse-community/parse-server-example.git

Now run following commands to install all nodejs dependencies.

cd parse-server-example
npm install 

Now edit index.js files and update APP_ID, MASTER_KEY and if required SERVER_URL as following. Use any random string for APP_ID and MASTER_KEY for test your setup.

vi index.js
var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://localhost:27017/parse',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'KSJ4KLJ5KJK435J3KSS9F9D8S9F8SD98F9SDF',
  masterKey: process.env.MASTER_KEY || 'KSJFKKJ3K4JK3J4K3JUWE89ISDJHFSJDFS',
  serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse',  
  ...

After making above changes run your parse server using the following command.

npm start 

//// Output
> parse-server-example@1.4.0 start /opt/parse-server-example
> node index.js

DATABASE_URI not specified, falling back to localhost.
parse-server-example running on port 1337.
info: Parse LiveQuery Server starts running

Step 4 – Test Parse Server

As your Parse server installation has been successfully completed. Do some tests to make sure it’s running.

First add some values to Parse server using curl command line tool. This will connect to parse server and records will be saved to MongoDB database. Change myAppId with your defined process.env.APP_ID in index.js.

curl -X POST \
  -H "X-Parse-Application-Id: myAppId" \
  -H "Content-Type: application/json" \
  -d '{"score":1337,"InventoryName":"Desktops","cheatMode":false}' \
  http://localhost:1337/parse/classes/Inventory

Result:

{"objectId":"aBacyYpPus","createdAt":"2016-09-14T19:16:19.254Z"}

Now use following command to fetch values from Parse server.

curl -X GET -H "X-Parse-Application-Id: myAppId"\
  http://localhost:1337/parse/classes/Inventory


Result:

{"results":[{"objectId":"aBacyYpPus","score":1337,"InventoryName":"Desktops","cheatMode":false,"createdAt":"2016-09-14T19:16:19.254Z","updatedAt":"2016-09-14T19:16:19.254Z"}]}

Conclusion

You have successfully installed and configured parse server on your system. Let’s setup Parse Dashboard to access Parse server data.

Share.

3 Comments

  1. npm ERR! path /root/package.json
    npm ERR! code ENOENT
    npm ERR! errno -2
    npm ERR! syscall open
    npm ERR! enoent ENOENT: no such file or directory, open ‘/root/package.json’
    npm ERR! enoent This is related to npm not being able to find a file.
    npm ERR! enoent

    npm ERR! A complete log of this run can be found in:
    npm ERR! /root/.npm/_logs/2019-01-20T06_35_55_608Z-debug.log
    root@ubuntu-2gb-nbg1-1:~#

    i always get this eror

  2. Hi, i want to deploy ubuntu server 16.04 on my local machine, and on a npm install i get err
    gyp ERR! build error
    gyp ERR! stack Error: `make` failed with exit code: 2
    gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
    gyp ERR! stack at emitTwo (events.js:106:13)
    gyp ERR! stack at ChildProcess.emit (events.js:194:7)
    gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
    gyp ERR! System Linux 4.4.0-116-generic
    gyp ERR! command “/usr/bin/nodejs” “/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” “rebuild”
    gyp ERR! cwd /home/milos/parse-server-example/node_modules/kerberos
    gyp ERR! node -v v7.10.1
    gyp ERR! node-gyp -v v3.5.0
    gyp ERR! not ok

    I edit a index.js file and replace localhost with 192.168.0.170
    And when i npm start i get err
    Error: ENOENT: no such file or directory, open ‘/home/milos/parse-server-example/logs/parse-server.info.2018-04-18’

    npm ERR! Linux 4.4.0-116-generic
    npm ERR! argv “/usr/bin/nodejs” “/usr/bin/npm” “start”
    npm ERR! node v7.10.1
    npm ERR! npm v4.2.0
    npm ERR! code ELIFECYCLE
    npm ERR! errno 7
    npm ERR! parse-server-example@1.4.0 start: `node index.js`
    npm ERR! Exit status 7
    npm ERR!
    npm ERR! Failed at the parse-server-example@1.4.0 start script ‘node index.js’.
    npm ERR! Make sure you have the latest version of node.js and npm installed.
    npm ERR! If you do, this is most likely a problem with the parse-server-example package,
    npm ERR! not with npm itself.
    npm ERR! Tell the author that this fails on your system:
    npm ERR! node index.js
    npm ERR! You can get information on how to open an issue for this project with:
    npm ERR! npm bugs parse-server-example
    npm ERR! Or if that isn’t available, you can get their info via:
    npm ERR! npm owner ls parse-server-example
    npm ERR! There is likely additional logging output above.

    npm ERR! Please include the following file with any support request:
    npm ERR! /home/milos/.npm/_logs/2018-04-18T10_00_37_531Z-debug.log

    And i dont have experiance with parse server and i want to have dash board. And i want to mention that i want it locally 192.168.0.170, and then how to deploy my app from server.

    Thanks in a advanced..

Leave A Reply

Exit mobile version