How To Install Parse Server on Ubuntu 18.04 & 16.04

Channel: Linux
Abstract: Now use following command to fetch values from Parse server. curl -X GET -H "X-Parse-Application-IdStep 4 – Test Parse Server As your Parse server ins

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.

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
> [email protected] 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.

Ref From: tecadmin

Related articles