Connect to your Ubuntu server using SSH
Before starting anything, you have to make sure you’re able to connect to your server using SSH.Command line
Output
Copy the code of your admin backend to your remote server
There are many ways to copy the code of your admin backend to a remote server. For example, you can usersync command, or use a versioning system like git.
rsync
rsync is a utility for efficiently transferring and synchronizing files across computer systems, by checking the timestamp and size of files. It is commonly found on Unix-like systems and functions as both a file synchronization and file transfer program. Rsync is typically used for synchronizing files and directories between two different systems.The syntax used is
(source: wikipedia)
rsync OPTIONS SOURCE TARGET.
Once done, you can find the code of your admin backend on the home directory of your remote server.
Command line
Output
git
First, you need to initialize a git repository for the code of your admin backend. From the directory of your admin backend, simply run:YourAccount to your account name:
Command line
Output
Command line
Output
Install dependencies
First, you have to make sure you have Node.js and NPM correctly installed on your server.Create the database
PostgreSQL
This step is optional if you already have a running database.
Command line
Output
rsync.
From your computer:
Command line
Output
Command line
Output
Export the environment variables
You must export the environment variablesFOREST_ENV_SECRET FOREST_AUTH_SECRET and DATABASE_URL. To do so, open and edit the file /etc/environment:
The FOREST_ENV_SECRET and FOREST_AUTH_SECRET environment variables will be given by Forest after creating a production environment from the interface. See how to create a production environment.
Run your admin backend
From your admin backend’s directory, simply type:Command line
Output
Manage Application with PM2
PM2 is a Production Runtime and Process Manager for Node.js applications with a built-in Load Balancer. It allows you to keep applications alive forever, to reload them without downtime and facilitate common Devops tasks. source: npmjs/pm2
Install PM2
Run your admin backend using PM2
(Optional) Set Up Nginx as a Reverse Proxy Server
Now that your admin backend is running and listening on localhost:3310, we will set up the Nginx web server as a reserve proxy to allow your admin panel’s users access it./etc/nginx/sites-available/default and replace the existing section location / by this one: