Skip to content

How to Deploy Dentic on a Remote Linux Server with Node.js, MySQL, PM2, and Nginx

  • by

This guide explains how to deploy Dentic, a full-stack dental care management system built with React and Node.js, on a remote Linux server such as an AWS EC2 instance, DigitalOcean Droplet, Azure VM, or another VPS.

Prerequisites

Before installing Dentic, make sure your server has:

  • Ubuntu 20.04 or newer, or Debian 11 or newer
  • At least 2 GB RAM
  • At least 2 vCPUs
  • Node.js 18 or newer
  • MySQL 8 or PostgreSQL 14 or newer
  • SSH access
  • A domain name for production use

Step 1 — Connect to the Dentic Server

Connect to your remote 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 — Download Dentic

Install Git:

sudo apt install git -y

Clone the Dentic repository:

git clone https://github.com/your-org/dentic.git

Open the project directory:

cd dentic/FRONTEND

Step 4 — Create the Dentic Database

For production, Dentic can use MySQL or PostgreSQL. The following example uses MySQL.

Install MySQL:

sudo apt install mysql-server -y

Run the MySQL security configuration:

sudo mysql_secure_installation

Open MySQL:

sudo mysql -u root -p

Create the Dentic database:

CREATE DATABASE dentic_db;

Create a database user:

CREATE USER 'dentic_user'@'localhost' IDENTIFIED BY 'StrongPassword!';

Grant privileges:

GRANT ALL PRIVILEGES ON dentic_db.* TO 'dentic_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Use a strong production password instead of the example password.

Step 5 — Configure the Dentic Backend

Open the backend directory:

cd backend

Create the environment file:

cp .env.example .env

Edit the Dentic backend environment:

nano .env

Configure the database and application settings:

PORT=5000
DB_HOST=localhost
DB_PORT=3306
DB_NAME=dentic_db
DB_USER=dentic_user
DB_PASSWORD=StrongPassword!

JWT_SECRET=your_super_secret_jwt_key

OPENAI_API_KEY=sk-...
TWILIO_ACCOUNT_SID=ACxxxxxxx
TWILIO_AUTH_TOKEN=xxxxxxx

FIREBASE_PROJECT_ID=your_firebase_project

Add the API credentials required by your Dentic installation.

Step 6 — Install Dentic Backend Dependencies

Install the backend packages:

npm install

If the project includes an initial seed script, run it:

node db/seeds.sequelize.js

Use the seed command only when initial data needs to be created.

Step 7 — Build the Dentic Frontend

Return to the Dentic frontend root:

cd ..

Install frontend dependencies:

npm install

Build the React application:

npm run build

This generates the production build directory.

If the Dentic frontend uses an environment variable for the API URL, configure it before building:

REACT_APP_API_URL=http://your_server_ip:5000 npm run build

For production, use your final HTTPS domain instead of the server IP.

Step 8 — Install PM2

Install PM2 globally:

sudo npm install -g pm2

Start the Dentic backend:

cd backend
pm2 start server.js --name dentic-backend

Start the Dentic frontend server:

cd ..
pm2 start server.js --name dentic-frontend

Save the PM2 processes:

pm2 save

Enable PM2 startup after reboot:

pm2 startup

Run the command printed by PM2.

Check the Dentic processes:

pm2 status

View backend logs:

pm2 logs dentic-backend

Step 9 — Configure Nginx for Dentic

Install Nginx:

sudo apt install nginx -y

Create an Nginx configuration for Dentic:

sudo nano /etc/nginx/sites-available/dentic

Add:

server {
    listen 80;
    server_name your_domain.com;

    location / {
        proxy_pass http://localhost:3001;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

    location /api/ {
        proxy_pass http://localhost:5000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Enable the Dentic site:

sudo ln -s /etc/nginx/sites-available/dentic /etc/nginx/sites-enabled/

Test the configuration:

sudo nginx -t

Reload Nginx:

sudo systemctl reload nginx

Step 10 — Enable HTTPS for Dentic

Install Certbot:

sudo apt install certbot python3-certbot-nginx -y

Create the SSL certificate:

sudo certbot --nginx -d your_domain.com

Certbot will configure HTTPS for the Dentic domain.

Step 11 — Verify Dentic

Open:

https://your_domain.com

The Dentic login page should load.

The Dentic backend API documentation is available at:

https://your_domain.com/api/api-docs

Troubleshooting Dentic

If the frontend or backend is not working, check the PM2 processes:

pm2 status

View the Dentic backend logs:

pm2 logs dentic-backend

For a port conflict, restart the Dentic processes:

pm2 delete all

Then start the Dentic frontend and backend again.