NavigationContentFooter
Jump toSuggest an edit

Installing Parse Server on Ubuntu 20.04

Reviewed on 03 June 2024Published on 03 November 2020
  • Parse-Server
  • Ubuntu
  • 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 that 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, analytics, and scheduling and sending 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 is 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 the 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.

The steps provided for installing Node.js on a Debian-based system like Ubuntu or Debian are generally still considered best practice. However, there have been some updates and improvements. Here is an updated set of instructions for installing Node.js:

  1. Update the system packages:

    sudo apt update
    sudo apt upgrade
  2. Install the required packages:

    sudo apt install -y ca-certificates curl gnupg
  3. Add the NodeSource APT repository:

    • Create the necessary directory:
      sudo mkdir -p /etc/apt/keyrings
    • Download and add the NodeSource GPG key:
      curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
    • Add the NodeSource repository:
      NODE_MAJOR=18
      echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
  4. Install Node.js:

    sudo apt update
    sudo apt install -y nodejs
  5. Verify the installation:

    node -v

These steps should install Node.js efficiently on your system. Additionally, you might consider using NVM (Node Version Manager) for greater flexibility in managing multiple Node.js versions, especially in a development environment.

Which returns Node.js latest 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 server attributes:

    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 the 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 the 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