How to Install Cezerin on Debian 9

In this tutorial, we will show you how to install Cezerin on a Debian 9 VPS.

Cezerin is an eCommerce platform powered by React, NodeJS, and MongoDB. It is an open-source platform that enables us to create progressive web apps for eCommerce. With Cezerin, your eCommerce website will load very fast because it is a single page application that only fetches JSON, and not HTML. Let’s begin with the installation.

Prerequisites

  • A Debian 9 server
  • Full SSH root access or a user with sudo privileges

Step 1: Log in via SSH and Update the System

Log in to your Debian 9 VPS.

ssh root@IP_Address -p Port_number

replace ‘IP_Address‘ and ‘Port_number‘ with the respective IP address and SSH port number that your server uses.

You can check whether you have the proper Debian version installed on your server with the following command:

# lsb_release -a

You should get this output:

Distributor ID: Debian
Description: Debian GNU/Linux 9.9 (Stretch)
Release: 9.9
Codename: stretch

Then, run the following command to make sure that all installed packages on the server are updated to their latest available versions:

# apt update && apt upgrade

This helps ensure that no mismatched versions or errors can occur. With that out of the way, we can start installing the packages that we’ll need.

Step 2: Install NodeJS

We need to install the latest stable version of Node.js and the npm package manager onto our server. To do that, we have to install the NodeSource Node.js repository first, as it is not a pre-installed software repository.

# apt install curl git build-essential software-properties-common
# curl -sL https://deb.nodesource.com/setup_10.x | bash -
# apt install nodejs

To check the Node.js version you have just installed after these initial steps, type:

# node -v

You should see an output similar to this.

v10.16.1

Step 3: Install MongoDB Server

Debian 9 official software package repositories come with version 3.2.11 of MongoDB, but in this article, we will install MongoDB 4.0 which is the latest available version. However, you can always check if a new version of MongoDB is available on their official website.

In order to install the MongoDB 4.0 Community Edition on Debian 9, we need to import the public key used by the package management system. We can do that with the command:

# apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4

Output:

Executing: /tmp/apt-key-gpghome.S7K61IhHP0/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
gpg: key 68818C72E52529D4: public key "MongoDB 4.0 Release Signing Key <packaging@mongodb.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1

Now, let’s create the ‘/etc/apt/sources.list.d/mongodb-org-4.0.list’ file using the following command:

# apt update

The repository has been enabled and packages list is updated so we can continue with installing the MongoDB package with the following command:

# apt install mongodb-org -y

MongoDB server has been installed, we can check the version with this command.

# mongod -version

You should have an output similar to this:

MongoDB shell version v4.0.11
git version: 417d1a712e9f040d54beca8e4943edce218e9a8c
OpenSSL version: OpenSSL 1.1.0k  28 May 2019
allocator: tcmalloc
modules: none
build environment:
    distmod: debian92
    distarch: x86_64
    target_arch: x86_64

That covers all of the dependencies, leaving us with the installation of Cezerin.

Step 4: Install Cezerin

In this step, we will download and install Cezerin from their GitHub repository.

We are going to put installation under the /opt/ directory – let’s go to the directory and download Cezerin:

# cd /opt
# git clone https://github.com/cezerin/cezerin.git cezerin

Now that Cezerin has been downloaded to /opt/cezerin, now let’s go to the directory and proceed with the installation:

# cd cezerin
# npm install
# npm run build

Next, run this command to add the default data and create the indices:

# npm run setup

Finally, we can start the project:

# npm start

You should see an output similar to this.

> cezerin@0.33.0 start /opt/cezerin
> concurrently npm:start-*

[start-store]
[start-store] > cezerin@0.33.0 start-store /opt/cezerin
[start-store] > node -r esm dist/store/server/index.js
[start-store]
[start-api]
[start-api] > cezerin@0.33.0 start-api /opt/cezerin
[start-api] > node -r esm src/api/server/index.js
[start-api]
[start-store] info: Store running at http://localhost:3000
[start-api] info: API running at http://localhost:3001
[start-api] info: MongoDB connected successfully

You can use Ctrl + C to stop the service, now let’s proceed to the next step.

Step 5: Create a systemd file

To manage the Cezerin service easier, we can create a systemd file. This is optional, but it does make using Cezerin a lot easier as it allows it to run in the background instead of in the terminal session. Open a new file using your preferred text editor:

nano /etc/systemd/system/cezerin.service

Add the following to the file:

[Unit]
Description=Cezerin

[Service]
ExecStart=/usr/bin/npm start
WorkingDirectory=/opt/cezerin
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=nodejs-example

[Install]
WantedBy=multi-user.target

When finished with editing the file, save and exit it.

Every time you create or edit a systemd file, you need to refresh the configuration by issuing this command:

# systemctl daemon-reload

Now let’s enable it to start automatically on boot as well as manually start the service now.

# systemctl enable cezerin
# systemctl start cezerin

At this point, you can access Cezerin at http://IP_Address:3000

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS

Step 6: Install and Configure Nginx as a Reverse Proxy

Cezerin has been successfully configured. However, if you want to access the application using your domain name instead of an IP address, as well as not require the port number, we need to install and configure a web server. For this tutorial, we will install and configure Nginx to proxy pass to Cezerin. Let’s start by installing Nginx:

# apt install nginx

Let’s create an Nginx server block file. make sure you change yourdomain.com with your actual domain name. Create this file using your preferred text editor and add these contents to it:

# nano /etc/nginx/sites-enabled/yourdomain.com.conf

And insert these lines to the file.

upstream cezerin {
     server 127.0.0.1:3000;
}

server {
listen 80;
server_name yourdomain.com;

location / {
     proxy_set_header Host $http_host;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header X-Forwarded-Proto $scheme;
     proxy_pass http://cezerin;
     }
}

Save and exit once finished. Next, check if there are errors using the first command. If there are none, you can then start Nginx. We also recommend enabling Nginx to start on boot as well:

# nginx -t
# systemctl restart nginx
# systemctl enable nginx

That’s it! Now you can access your Cezerin installation from http://yourdomain.com.


Of course, you don’t have to know how to install Cezerin on Debian 9 if you have a Debian VPS Hosting plan with us. Because our servers are fully managed, you can simply ask our support team to install Cezerin on Debian 9 for you. They are available 24/7, and will be able to help you with the installation of Cezerin on Debian.

PS. If you enjoyed reading this blog post on how to install Cezerin on Debian 9, feel free to share it on social networks using the shortcuts below, or simply leave a comment in the comments section. Thanks.

Leave a Comment