NavigationContentFooter
Jump toSuggest an edit

Installing Parse Server on Ubuntu 20.04

Reviewed on 27 November 2023Published on 03 November 2020
  • advanced
  • settings
  • Parse-Server
  • Ubuntu-20.04
  • MongoDB

Parse provides a cloud-based backend service to build data-driven mobile applications quickly. Initially developed by Facebook, Parse is a free and open-source Backend as-a-Service (BaaS) platform which can be deployed to any infrastructure that runs NodeJS. It can be added to existing web applications, or run by itself. Parse server comes with a simple and easy-to-use web interface that can be used for data manipulation, to view analytics, and to schedule and send push notifications.

Before you start

To complete the actions presented below, you must have:

  • A Scaleway account logged into the console
  • Owner status or IAM permissions allowing you to perform actions in the intended Organization
  • An SSH key
  • An Instance running on Ubuntu Focal Fossa or later

Installing MongoDB

MongoDB is a document-oriented database that is free and open-source. It considered one of the most popular NoSQL database engines because it is scalable, powerful, reliable and easy to use. In contrast to relational databases, MongoDB does not require a deep predefined schema before you can add data since it can be altered at any time.

  1. Update Ubuntu package manager.
    apt update
  2. Upgrade the Ubuntu packages already installed.
    apt upgrade
  3. Install MongoDB. By default, MongoDB is available in the Ubuntu 20.04 default repository.
    apt install mongodb-server -y
  4. Verify MongoDB status.
    systemctl status mongodb.service
    ● mongodb.service - An object/document-oriented database
    Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor preset: enabled)
    Active: active (running) since Tue 2020-11-03 15:43:50 UTC; 22s ago
    Docs: man:mongod(1)
    Main PID: 718 (mongod)
    Tasks: 23 (limit: 4915)
    Memory: 42.2M
    CGroup: /system.slice/mongodb.service
    └─718 /usr/bin/mongod --unixSocketPrefix=/run/mongodb --config /etc/mongodb.conf
    Nov 03 15:43:50 scw-friendly-edison systemd[1]: Started An object/document-oriented database.

Installing Node.js

By default, Node.js is not available in the Ubuntu 20.04 default repository. Therefore Node.js needs to be added to the repository of your system. In addition, ensure curl is installed on your system.

  1. Add an external repository for the required version of Node.js. Make sure to replace NODE_MAJOR with the version number of the latest node runtime.

    apt update
    apt install -y ca-certificates curl gnupg
    mkdir -p /etc/apt/keyrings
    curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
    NODE_MAJOR=18
    echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
  2. Install Node.js.

    apt install nodejs -y
  3. Install yarn package manager.

    npm install -g yarn
  4. Verify the Node.js version.

    node --version

    Which returns Node.js lastest version:

    v18.16.0

Installing Parse Server

  1. Install the parse-server module using the Yarn package manager.

    yarn global add parse-server
    ...
    success Installed "parse-server@6.1.0" with binaries:
    - parse-server
  2. Create a Parse server configuration file and define the attributes of the parse server.

    nano config.json
  3. Add the following lines:

    {
    "appName": "Parse Server Application",
    "databaseURI": "mongodb://localhost:27017/parsedb",
    "appId": "SCWASRTWK9Y6AVMP3KFC",
    "masterKey": "LASDK823JKHR87SDFJSDHF8DFHASFDF",
    "serverURL": "https://localhost:1337/parse",
    "publicServerURL": "https://0.0.0.0:1337/parse",
    "port": 1337
    }

    The configuration details are as follows:

    • appName: Set any name for your Parse server
    • databaseURI: Connection string to the MongoDB database
    • appID: Set a random string as appID, which will be used to connect the server.
    • masterKey: Set a random string for the master key.
    • serverURL: Set a URL for your parse server
    • publicServerURL: Set a public URL for your parse server
    • port: Indicate the server port
  4. Save and close the file.

  5. Start the Parse server.

    Note

    The nohup command allows you to manually start the Parse server. However, the downside of this procedure is that if the instance on which the Parse server is installed fails, the Parse server will not restart automatically.

    nohup parse-server config.json &
  6. Run the following command to verify that the Parse server is listening on port 1337 (mentioned in the configuration file):

    ss -ant | grep 1337
    LISTEN 0 511 0.0.0.0:1337 0.0.0.0:*

Turning Parse Server into a service with systemd

Creating a systemd service file allows you to automatically run and manage your application. It will restart in case of a failure (unexpected exit), and even survive server restarts.

  1. Create a file called parse.server.service from /etc/systemd/system/.

    nano parse.server.service
  2. Copy the following lines.

    [Unit]
    Description=Parse Server service
    After=mongodb.service
    StartLimitIntervalSec=0
    [Service]
    Type=simple
    Restart=always
    RestartSec=1
    User=ubuntu
    ExecStart=/usr/local/bin/parse-server /ubuntu/config.json
    [Install]
    WantedBy=multi-user.target

    The configuration details are as follows:

    • Description: Define a name for your service
    • After: Define after which service the application starts
    • User: Set your actual username
    • ExecStart: Set the proper path to your script
  3. Save and close the file.

  4. Start the Parse server.

    systemctl start parse.server.service
  5. Verify the status of the Parse server.

    systemctl status parse.server.service
    Warning: The unit file, source configuration file or drop-ins of parse.server.service changed on disk. Run 'systemctl daemon-reload' to reload units.
    ● parse.server.service - Parse Server service
    Loaded: loaded (/etc/systemd/system/parse.server.service; disabled; vendor preset: enabled)
    Active: active (running) since Tue 2020-11-10 12:28:20 UTC; 1h 13min ago
    Main PID: 18097 (node)
    Tasks: 11 (limit: 4915)
    Memory: 63.2M
    CGroup: /system.slice/parse.server.service
    └─18097 node /usr/local/bin/parse-server /root/config.json
  6. Get it to automatically start on boot.

    systemctl enable parse.server.service

Configuring Parse Server dashboard

Parse server comes with a Dashboard for managing your Parse server applications. It is accessible through a web browser.

  1. Install Parse dashboard.

    yarn global add parse-dashboard
    success Installed "parse-dashboard@2.1.0" with binaries:
    - parse-dashboard
  2. Create a configuration file for the Parse dashboard.

    nano parse-dashboard-config.json
  3. Add the following lines. Do not forget to replace your server IP address.

    {
    "apps": [
    {
    "serverURL": "http://your-server-ip:1337/parse",
    "appId": "SCWASRTWK9Y6AVMP3KFC",
    "masterKey": "LASDK823JKHR87SDFJSDHF8DFHASFDF",
    "allowInsecureHTTP": "true",
    "appName": "ParseApp"
    }
    ],
    "users": [
    {
    "user":"scaler1",
    "pass":"scalewayrocks"
    }
    ],
    "iconsFolder": "icons"
    }

    The configuration details are as follows:

    • serverURL: Set a URL for your parse server
    • appID: Set a random string as appID, which will be used to connect the server.
    • masterKey: Set a random string for the master key.
    • appName: Set any name for your Parse server
    • user: Set the username to connect to the Parse Dashboard
    • pass: Set the password to connect to the Parse Dashboard
  4. Save and close the file.

  5. Start the Parse server Dashboard.

    Note

    The nohup command allows you to manually start the Parse server. However, the downside of this procedure is that if the instance on which the Parse server is installed fails, the Parse server will not restart automatically.

    nohup parse-dashboard --dev --config parse-darshboard-config.json &
  6. Run the following command to verify that the Parse server Dashboard is listening on port 4040.

    ss -ant | grep 4040
    LISTEN 0 511 0.0.0.0:4040 0.0.0.0:*

Turning Parse Server dashboard into a service with systemd

  1. Create a file called parse.server.dashboard.service from /etc/systemd/system/.

    nano parse.server.dashboard.service
  2. Copy the following lines:

    [Unit]
    Description=Parse Server Dashboard service
    After=parse.server.service
    StartLimitIntervalSec=0
    [Service]
    Type=simple
    Restart=always
    RestartSec=1
    User=ubuntu
    ExecStart=/usr/local/bin/parse-dashboard --dev --config /ubuntu/parse-dashboard-config.json
    [Install]
    WantedBy=multi-user.target

    In the example above, the After directive implies that the Parse server Dashboard service starts after the Parse server service itself.

  3. Start the Parse server Dashboard service.

    systemctl start parse.server.dashboard.service
  4. Verify the status of the Parse server.

    systemctl status parse.server.dashboard.service
    parse.server.dashboard.service - Parse Server Dashboard service
    Loaded: loaded (/etc/systemd/system/parse.server.dashboard.service; disabled; vendor preset: enabled)
    Active: active (running) since Tue 2020-11-10 12:39:56 UTC; 1h 17min ago
    Main PID: 18312 (node)
    Tasks: 11 (limit: 4915)
    Memory: 24.0M
    CGroup: /system.slice/parse.server.dashboard.service
    └─18312 node /usr/local/bin/parse-dashboard --dev --config /root/parse-darshboard-config.json

Accessing the Parse Server dashboard

  1. Access the Parse server dashboard by visiting the URL http://your-server-ip:4040
  2. Add the credentials that you entered in the parse-darshboard-config.json file.
Docs APIScaleway consoleDedibox consoleScaleway LearningScaleway.comPricingBlogCarreer
© 2023-2024 – Scaleway