By Hitesh Jethva, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud's incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.
Parse server is a free and open source Mobile Backend as a Service platform originally developed by the provider Parse, Inc. You can deploy Parse server to any infrastructure that can run Node.js and can be added to existing web applications. Parse Server is a new project, separate from the hosted Parse API service. Its main aim is to provide and support the growth of an open-source API server, and allow new developers to benefit from the powerful Parse client SDKs regardless of where their application logic and data is stored. Parse server comes with a lot of features such as, analytics, global configuration, push notifications, background jobs, system emails and much more.
In this tutorial, we will learn how to install Parse Server on an Alibaba Cloud Elastic Compute Service (ECS) Ubuntu 16.04 Server
First, log in to your Alibaba Cloud ECS Console. Create a new ECS instance, choosing Ubuntu 16.04 as the operating system with at least 2GB RAM. Connect to your ECS instance and log in as the root user.
Once you are logged into your Ubuntu 16.04 instance, run the following command to update your base system with the latest available packages.
apt-get update -y
You will need to install the MongoDB database server to your system. By default, MongoDB is not available in the Ubuntu 16.04 default repository. So, you will need to add the PPA for that.
First, install the required packages with the following command:
apt-get install build-essential git python-software-properties -y
Next, add the MongoDB repository with the following command:
echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/4.0 multiverse" | tee /etc/apt/sources.list.d/mongodb.list
Update the repository and install MongoDB server using the following command:
apt-get update -y
apt-get install mongodb -y
Once the installation is completed. You can check the MongoDB status with the following command:
systemctl status mongodb
Output:
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.
By default, Node.js is not available in the Ubuntu 16.04 default repository. So, you will need to add the PPA for that. You can do this with the following command:
curl -sL https://deb.nodesource.com/setup_8.x | bash -
Once the repository is installed, install Node.js with the following command:
apt-get install nodejs -y
Update the NPM packages to the latest version by running the following command:
npm i npm@latest -g
Download the example parse server from Git repository with the following command:
git clone https://github.com/ParsePlatform/parse-server-example.git
Change the directory to the parse-server-example and install all nodejs dependencies using the following command:
cd parse-server-example
npm install
Once the installation has been completed, you should see the following output:
> 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-server
npm 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
Next, fix some vulnerabilities using the following command:
npm audit fix
Output:
+ 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
All the Node.js dependencies are now installed. It's time to test sample application. You can test it by running the following command:
npm start
Once the server starts, you should see the following output:
> 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.
Your Parse server is now up and listening on port 1337. Let's perform some tests to make sure it's running.
Add some values to Parse server using the curl command.
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
Output:
{"objectId":"jfHaj1uVi4","createdAt":"2018-09-02T09:06:02.960Z"}
This command will connect to parse server and records will be saved to MongoDB database.
Now, fetch values from Parse server using the following command:
curl -H "X-Parse-Application-Id: myAppId" http://localhost:1337/parse/classes/GameScore
If everything goes fine, you should see the following output:
{"results":[{"objectId":"jfHaj1uVi4","score":1337,"playerName":"Sammy","cheatMode":false,"createdAt":"2018-09-02T09:06:02.960Z","updatedAt":"2018-09-02T09:06:02.960Z"}]}
Create a sample app with name testapp.js:
nano testapp.js
Add the following lines:
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 + '.');
});
Save and close the file. Then, run the app with the following command:
node testapp.js
Output:
parse-server-example running on port 9999.
Test the testapp with the following command:
curl -H "X-Parse-Application-Id: TestAppId" http://localhost:9999/myparseapp/classes/GameScore
Output:
{"results":[{"objectId":"jfHaj1uVi4","score":1337,"playerName":"Sammy","cheatMode":false,"createdAt":"2018-09-02T09:06:02.960Z","updatedAt":"2018-09-02T09:06:02.960Z"}]}
That's it! Parse Server is now successfully installed on your Alibaba Cloud Elastic Compute Service (ECS) Ubuntu 16.04 Server.
2,599 posts | 762 followers
FollowAlibaba Clouder - August 19, 2020
Alibaba Clouder - May 6, 2019
Alibaba Clouder - February 13, 2018
Alibaba Clouder - May 7, 2019
Alibaba Clouder - April 23, 2019
Alibaba Clouder - June 11, 2018
2,599 posts | 762 followers
FollowElastic and secure virtual cloud servers to cater all your cloud hosting needs.
Learn MoreAlibaba Cloud Function Compute is a fully-managed event-driven compute service. It allows you to focus on writing and uploading code without the need to manage infrastructure such as servers.
Learn MoreMarketplace is an online market for users to search and quickly use the software as image for Alibaba Cloud products.
Learn MoreMore Posts by Alibaba Clouder