Deploy a Node app on your cPanel account

Every RTL hosting account can run Node.js applications — Express APIs, Next.js sites, NestJS services and more — straight from cPanel, alongside your existing websites and email.

Apps run under the Phusion Passenger application server, managed from the Application Manager icon in cPanel. There is no extra charge and no separate control panel to learn.

What's on the server

  • Node.jsv22.23.2
  • npm10.9.8
  • App serverPhusion Passenger 6.1.8
  • Node binary/opt/cpanel/ea-nodejs22/bin/node
  • Apps per account4 (more on request)
  • WebSocketsSupported

Before you start

Terminal access

You need shell access to install packages and build your app. Open Terminal in cPanel, or ask us to enable SSH on your account. It is free — just email support.

Your code

A Node project with a package.json. You can pull it from GitHub using cPanel's Git Version Control, or upload a zip through File Manager.

A domain or subdomain

Each app is served by one domain or subdomain. We recommend a dedicated subdomain such as app.yourdomain.com — it keeps the app clear of your main site's rules.

Step by step

The example below deploys an app called myapp for the account myuser on app.yourdomain.com. Substitute your own names throughout.

  1. Create the subdomain and its folder

    In cPanel go to Domains → Create A New Domain. Enter app.yourdomain.com, untick Share document root, and set the document root to:

    /home/myuser/myapp/public

    This matters: Passenger expects your application folder to be /home/myuser/myapp and it serves static files out of a public sub-folder inside it. The public folder must exist, even if it stays empty — the app will not start without it.

  2. Put your code in place

    Your project files go in /home/myuser/myapp — one level above the document root. The easiest route is cPanel's Git Version Control: click Create, tick Clone a Repository, paste your repo URL and set the path to /home/myuser/myapp.

    Or from Terminal:

    cd ~
    git clone https://github.com/you/myapp.git myapp
    mkdir -p myapp/public
  3. Add an entry point named app.js

    Passenger starts your application by loading app.js in the application folder. Your app must listen on the port Passenger provides in process.env.PORT.

    A plain Node or Express app:

    // app.js
    const express = require('express');
    const app = express();
    
    app.get('/', (req, res) => res.send('Hello from RTL'));
    
    app.listen(process.env.PORT || 3000);

    A Next.js app needs a small custom server. Create this as app.js next to your package.json:

    // app.js
    const { createServer } = require('http');
    const next = require('next');
    
    const app = next({ dev: false, dir: __dirname });
    const handle = app.getRequestHandler();
    
    app.prepare().then(() => {
      createServer((req, res) => handle(req, res))
        .listen(process.env.PORT || 3000);
    });
  4. Install dependencies and build

    Open Terminal in cPanel. Put the server's Node on your path first — the system node is not the one your app will run under:

    export PATH=/opt/cpanel/ea-nodejs22/bin:$PATH
    cd ~/myapp
    npm ci
    npm run build     # Next.js and other build steps

    Add that export line to your ~/.bashrc so you do not have to repeat it each session.

  5. Register the app in Application Manager

    In cPanel open Application Manager (under Software) and click Register Application. Fill in:

    • Application Name myapp
    • Application Path /home/myuser/myapp
    • Domain app.yourdomain.com
    • Base Application URI /
    • Deployment Environment Production

    Add any environment variables your app needs (database URLs, API keys, NODE_ENV) under Add Environment Variable. Tick Enabled and save. Your app is now live.

  6. Restarting after a change

    Passenger keeps your app running between requests, so new code is not picked up until you restart it. Either hit Restart in Application Manager, or from Terminal:

    cd ~/myapp
    mkdir -p tmp
    touch tmp/restart.txt

    The next request will start a fresh process.

  7. Optional: deploy on git push

    If you cloned with Git Version Control, add a .cpanel.yml file to the root of your repository so a push rebuilds and restarts the app automatically:

    ---
    deployment:
      tasks:
        - export PATH=/opt/cpanel/ea-nodejs22/bin:$PATH
        - cd /home/myuser/myapp
        - /opt/cpanel/ea-nodejs22/bin/npm ci
        - /opt/cpanel/ea-nodejs22/bin/npm run build
        - mkdir -p /home/myuser/myapp/tmp
        - touch /home/myuser/myapp/tmp/restart.txt

    Then push your changes and click Deploy HEAD Commit in Git Version Control.

If something goes wrong

You get a 404 instead of your app

Almost always a missing public folder inside the application path, or a document root that does not end in /public. Check both, then restart the app.

"We're sorry, something went wrong"

That is Passenger reporting a crash on startup. Set the Deployment Environment to Development in Application Manager to see the stack trace in your browser, fix it, then switch back to Production.

Wrong Node version at build time

Running node -v in Terminal shows the system Node, not the app's. Always export PATH=/opt/cpanel/ea-nodejs22/bin:$PATH before npm commands.

Your changes are not showing

The old process is still serving requests. Restart the app from Application Manager or touch tmp/restart.txt.

Stuck, or want us to do the first deployment for you? We are happy to help.

Contact Support
Get in Touch