How to Install Parse Server on Ubuntu 16.04

Prerequisites

  1. A fresh Alibaba Cloud ECS Ubuntu 16.04 instance.
  2. A static IP address is configured.
  3. A root password is set up to your instance.

Launch Alibaba Cloud ECS Instance

apt-get update -y

Install MongoDB

apt-get install build-essential git python-software-properties -y
echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/4.0 multiverse" | tee /etc/apt/sources.list.d/mongodb.list
apt-get update -y
apt-get install mongodb -y
systemctl status mongodb
mongodb.service - An object/document-oriented database
Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2018-09-02 14:24:18 IST; 33s ago
Docs: man:mongod(1)
Main PID: 13600 (mongod)
CGroup: /system.slice/mongodb.service
└─13600 /usr/bin/mongod --config /etc/mongodb.conf
Sep 02 14:24:18 mail.example.com systemd[1]: Started An object/document-oriented database.
Sep 02 14:24:46 mail.example.com systemd[1]: Started An object/document-oriented database.

Install Node.js

curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt-get install nodejs -y
npm i npm@latest -g

Install and Configure Parse Server

git clone https://github.com/ParsePlatform/parse-server-example.git
cd parse-server-example
npm install
> parse-server@3.0.0 postinstall /opt/parse-server-example/node_modules/parse-server
> node -p 'require("./postinstall.js")()'
1111111111
1111111111111111
1111111111111111111111
11111111111111111111111111
111111111111111 11111111
1111111111111 111111
1111111111111 111111111 111111
111111111111 11111111111 111111
1111111111111 11111111111 111111
1111111111111 1111111111 111111
1111111111111111111111111 1111111
11111111 11111111
111111 1111111111111111111
11111 11111 111111111111111111
11111 11111111111111111
111111 111111111111111111
11111111111111111111111111
1111111111111111111111
111111111111111111
11111111111
Thanks for installing parse ??
Please consider donating to our open collective
to help us maintain this package.
?? https://opencollective.com/parse-servernpm notice created a lockfile as package-lock.json. You should commit this file.
added 411 packages from 370 contributors and audited 744 packages in 73.889s
found 17 vulnerabilities (4 low, 9 moderate, 4 high)
run `npm audit fix` to fix them, or `npm audit` for details
npm audit fix
+ express@4.16.3
added 16 packages from 22 contributors, removed 3 packages and updated 26 packages in 26.245s
fixed 17 of 17 vulnerabilities in 744 scanned packages

Test Sample Application

npm start
> parse-server-example@1.4.0 start /opt/parse-server-example
> node index.js
DATABASE_URI not specified, falling back to localhost.
(node:13705) ExperimentalWarning: The http2 module is an experimental API.
(node:13705) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
parse-server-example running on port 1337.
(node:13705) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
curl -X POST -H "X-Parse-Application-Id: myAppId" -H "Content-Type: application/json" -d '{"score":1337,"playerName":"Sammy","cheatMode":false}' http://localhost:1337/parse/classes/GameScore
{"objectId":"jfHaj1uVi4","createdAt":"2018-09-02T09:06:02.960Z"}
curl -H "X-Parse-Application-Id: myAppId" http://localhost:1337/parse/classes/GameScore
{"results":[{"objectId":"jfHaj1uVi4","score":1337,"playerName":"Sammy","cheatMode":false,"createdAt":"2018-09-02T09:06:02.960Z","updatedAt":"2018-09-02T09:06:02.960Z"}]}

Configure Sample Application

nano testapp.js
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
// Configure the Parse API
var api = new ParseServer({
databaseURI: 'mongodb://localhost:27017/dev',
cloud: __dirname + '/cloud/main.js',
appId: 'TestAppId',
masterKey: 'TestMasterKey'
});
var app = express();// Serve the Parse API on the /parse URL prefix
app.use('/myparseapp', api);
// Listen for connections on port 1337
var port = 9999;
app.listen(port, function() {
console.log('parse-server-example running on port ' + port + '.');
});
node testapp.js
parse-server-example running on port 9999.
curl -H "X-Parse-Application-Id: TestAppId" http://localhost:9999/myparseapp/classes/GameScore
{"results":[{"objectId":"jfHaj1uVi4","score":1337,"playerName":"Sammy","cheatMode":false,"createdAt":"2018-09-02T09:06:02.960Z","updatedAt":"2018-09-02T09:06:02.960Z"}]}

--

--

--

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Dynamically Generating DB Credentials via Vault

Programming GPU across the Language Boundaries

Introducing Alibaba Cloud Express Connect

Why and how we have changed all our monitoring stack

The 5 Misconceptions of Sponsoring a Virtual Conference

Basic Commands in Linux

Run Fn Project on your Raspberry Pi

VMware vCenter Deployment and Best Practices

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

More from Medium

Securing MQTT Traffic with Cloud Internet Services

Paging by Search After — ElasticSearch

Publish Data from Micro:bit v2 to Qubitro IoT Platform

Options For Building Real-Time Apps