Skip to content

How to Deploy UpRecruit on an Ubuntu VPS with Node.js and PostgreSQL

  • by

This guide explains how to deploy UpRecruit, a recruitment management platform built with React.js, Node.js, Express, and PostgreSQL, on an Ubuntu or Debian VPS.

Prerequisites

Before installing UpRecruit, make sure you have:

  • An Ubuntu 22.04 or Debian 12 VPS
  • SSH access with sudo privileges
  • A domain name, if you want to use a custom domain
  • PostgreSQL
  • Stripe API keys

Step 1 — Connect to the VPS

Connect to your server using SSH:

ssh your_user@your_server_ip

Step 2 — Install Node.js and npm

Install Node.js 18:

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs

Verify the installation:

node -v
npm -v

Step 3 — Install PostgreSQL for UpRecruit

Update the package list:

sudo apt update

Install PostgreSQL:

sudo apt install -y postgresql postgresql-contrib

Enable and start PostgreSQL:

sudo systemctl enable postgresql
sudo systemctl start postgresql

Create the UpRecruit database:

sudo -u postgres psql

Run:

CREATE DATABASE uprecruit;
CREATE USER uprecruit_user WITH ENCRYPTED PASSWORD 'your_strong_password';
GRANT ALL PRIVILEGES ON DATABASE uprecruit TO uprecruit_user;
\q

Use a strong production password instead of the example password.

Step 4 — Install PM2

PM2 keeps the UpRecruit Node.js processes running after an SSH session ends and allows them to restart automatically after a server reboot.

Install PM2:

sudo npm install -g pm2

Step 5 — Download UpRecruit

Navigate to the application directory:

cd /var/www

Clone the UpRecruit repository:

sudo git clone https://github.com/your-org/uprecruit.git

Set ownership:

sudo chown -R $USER:$USER /var/www/uprecruit

Open the project directory:

cd /var/www/uprecruit

Step 6 — Configure the UpRecruit Backend

Open the backend configuration file:

nano /var/www/uprecruit/backend/connection.sequelize.js

Configure the PostgreSQL connection:

module.exports = {
    HOST: "localhost",
    USER: "uprecruit_user",
    PASSWORD: "your_strong_password",
    DB: "uprecruit",
    dialect: "postgres",
    port: 5432,
    pool: {
        max: 5,
        min: 0,
        acquire: 30000,
        idle: 10000
    }
};

Create the UpRecruit backend environment file:

nano /var/www/uprecruit/backend/.env

Add:

STRIPE_SECRET_KEY=sk_live_YOUR_LIVE_KEY
STRIPE_WEBHOOK_SECRET=whsec_YOUR_WEBHOOK_SECRET
CLIENT_URL=https://yourdomain.com
PORT=5000

Step 7 — Install UpRecruit Dependencies

Install backend dependencies:

cd /var/www/uprecruit/backend
npm install

Install frontend dependencies:

cd /var/www/uprecruit
npm install

Step 8 — Build the UpRecruit Frontend

Build the React frontend:

cd /var/www/uprecruit
npm run build

This creates the production build directory used by the UpRecruit frontend server.

Step 9 — Start UpRecruit with PM2

Start the backend API:

cd /var/www/uprecruit/backend
pm2 start server.js --name "uprecruit-api"

Start the UpRecruit frontend:

cd /var/www/uprecruit
pm2 start server.js --name "uprecruit-frontend"

Save the PM2 process list:

pm2 save

Configure PM2 to start automatically after reboot:

pm2 startup

Run the command displayed by PM2.

Step 10 — Configure the Firewall

Allow SSH:

sudo ufw allow OpenSSH

Allow the UpRecruit frontend:

sudo ufw allow 3001/tcp

Allow the UpRecruit backend:

sudo ufw allow 5000/tcp

Enable the firewall:

sudo ufw enable

Step 11 — Verify UpRecruit

Check the PM2 processes:

pm2 status

Test the frontend:

curl http://localhost:3001

Test the backend API:

curl http://localhost:5000/api

The UpRecruit application should now be accessible through the server IP and the configured frontend port.