Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save dosanauthor/30e19507766b70dfa1540ec02453624d to your computer and use it in GitHub Desktop.

Select an option

Save dosanauthor/30e19507766b70dfa1540ec02453624d to your computer and use it in GitHub Desktop.

1. Ensure Node.js is Installed via WHM

  • Log into WHM: https://your-server-ip:2087
  • Go to EasyApache 4 > Currently Installed Packages > Customize
  • In Additional Packages, search for nodejs18 or nodejs20 and enable it.
  • In Apache Modules, search for mod-passenger and enable it.

2. Create a cPanel User

  • WHM > List Accounts > Create a New Account > set domain, username, password, email

3. Log Into cPanel as That User

  • Go to: https://your-server-ip:2083

4. Upload Your App Project Files

  • Go to: File Manager
  • Upload and unzip your project folder inside the home directory (e.g., /home/your-cpanel-username/pdf-tools-all-in-one).

5. Add Domain and Update DNS Records

  • cPanel > Domains > Domains > Create a New Domain

    • Enter the domain (e.g., yourdomain.com) (If not already done)
    • Set the Document Root to your app’s folder (e.g., /pdf-tools-all-in-one) (If not already done)
  • Update DNS Records: In your domain registrar’s DNS settings, add:

    • Record 01:
      • Type: A Record | Name: @ | Points to: your-server-ip
    • Record 02:
      • Type: CNAME Record | Name: www | Points to: yourdomain.com

6. Create Node.js Application

In cPanel, under the Software section, you’ll see either Setup Node.js App or Application Manager, depending on your OS.

Option A : Setup Node.js App

A-1. Create Node.js App

  • Go to cPanel > Software > Setup Node.js App

  • Click Create Application

    • Node.js Version ➡️ 18 LTS (or 20)
    • Application Mode ➡️ Production
    • Application Root ➡️ /pdf-tools-all-in-one (The directory where your app files are located.)
    • Application URL ➡️ The domain you added earlier (e.g., yourdomain.com)
    • Application Startup File ➡️ app.js
    • Environment Variables ➡️ Leave this section as it is.
  • Click Create, then Start

A-2. Install Dependencies

  • In Node.js App section, click Run NPM Install

A-3. Build Your App (via SSH)

open a terminal and log in to your VPS using the following command:

ssh root@your-server-ip

or

ssh [email protected]

and enter password (VPS login password)

Navigate to the project directory and install the dependencies using the following commands:

cd /home/your-cpanel-username/pdf-tools-all-in-one

npm run build

PS: Replace your-cpanel-username with your cPanel username


A-4. Restart the App

  • In Setup Node.js App, click Restart

Then visit your domain to check if it's working: https://yourdomain.com

A-5. Updating the code

  • After making changes to the code.
  • Open a terminal, navigate to the project directory and run the command: npm run build
  • Click Restart
  • Refresh the page

Option B : Application Manager

B-1. Create Node.js App

  • cPanel > Software > Application Manager

  • Click Register Application

    • Application Name ➡️ pdftools
    • Deployment Domain ➡️ yourdomain.com (The domain you added earlier)
    • Base Application URL ➡️ /
    • Application Path ➡️ pdf-tools-all-in-one
    • Deployment Environment ➡️ Production
  • Click Deploy


B-2. Install Dependencies

  • Click Ensure Dependencies

B-3. Build Your App (via SSH)

open a terminal and log in to your VPS using the following command:

ssh root@your-server-ip

or

ssh [email protected]

and enter password (VPS login password)

Navigate to the project directory and install the dependencies using the following commands:

cd /home/your-cpanel-username/pdf-tools-all-in-one

npm run build

PS: Replace your-cpanel-username with your cPanel username

Then visit your domain to check if it's working: https://yourdomain.com

B-4. Updating the code

  • After making changes to the code.
  • Open a terminal, navigate to the project directory and run the command: npm run build
  • Switch off the Enabled button and then switch it on.
  • Refresh the page

7. 🛠 Depending on your OS Install The Following Required Dependencies (You may consult ChatGPT to obtain the appropriate commands for your operating system):

Ghostscript

Libreoffice

qpdf

Verify Installation by running the following commands:

  • gs --version
  • libreoffice --version
  • qpdf --version

Each should return the version number.

💡 Tips

  • Ensure your domain DNS points to the VPS.
  • Ensure DNS is properly propagated before testing.
  • If you encounter issues running commands to install dependencies or build the application via the cPanel terminal, consider using the SSH terminal from your local machine instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment