Skip to content

Deploy NodeJS website

Suppose you have a nodejs website that you want to run under domain api.domain.com

  1. Make sure the two applications NodeJS and PM2 are installed on the server. See the installation guide at Application Management.

  2. Create a website with the appropriate configuration:

    • Go to the server management page, click on the Sites menu in the sidebar, then click the Create Website button
    • Enter the domain (e.g., api.domain.com)
    • Enter the Proxy Port — the port your nodejs application runs on, for example 3000
  3. Install the source code for the website from git or upload it yourself. See the detailed guide at Source Code Installation. To access it, go to the site management page and click on the Source Code menu in the sidebar.

  4. Start your nodejs application on production:

    • Locally, you typically start nodejs with the command node index.js
    • On production, if you have installed the PM2 application, you can use the PM2 Dashboard on the server management page to add a new process. Click the Add New button, enter the command index.js --name my-api and click Start
    • Alternatively, you can run the command manually via SSH: pm2 start index.js --name my-api
  5. When you update new code, you need to restart the process:

    • If using the PM2 Dashboard, click the Restart button for your process
    • Or run the command: pm2 restart my-api