Using NodeJS Apps Print

  • 0

Using NodeJS Apps

cPanel supports Node.js applications, ideal for building real-time, interactive web applications with two-way communication between client and server. Here’s how to set up and manage a Node.js application on cPanel.

Steps to Configure a Node.js Application on cPanel:

  1. Log into cPanel:

    • Click on Setup Node.js App to open the configuration screen.

  

  1. Set Up Application Details:

    • Application Root: Specify the folder where all Node.js files are stored. Ensure the path is correct, or module imports may fail.
    • Application URL: Enter the URL where you want your Node.js application to be accessible.
    • Application Startup File: Indicate the main entry point for your Node.js app, typically containing the HTTP server listening on a specific port, data connectivity strings, and module imports. If configured correctly, your application will be proxied and accessible on ports 80 and 443.
    • Error Log Location: Define the location for error logs (typically in the passenger log file field), though this is optional.

Working with Popular Frameworks

Express.js

Express.js is a popular web API framework used for RESTful services. To install Express.js:

npm install express

After setup, navigating to your application’s URL should return a “Hello World!” response if everything is configured correctly.

Front-End Frameworks: React, AngularJS, Vue.js, Nuxt.js, and Next.js

  1. Development and Build:

    • For frameworks like React, Angular, and Vue.js, development is done locally. Use the following command to build the application:
      npm run build
    • Example commands:
      • Vue.js: vue-cli-service build --no-clean
      • React.js: react-scripts build
  2. Deploy Static Files:

    • These frameworks generate static HTML files with precompiled JavaScript in CommonJS format. Transfer these files to the website’s document root using SSH, FTP, or a CI setup for automatic deployment on git pushes.
  3. Nuxt.js and Next.js:

    • These frameworks support Server-Side Rendering (SSR) and involve both a web application and a listening server.
    • While hosting them on cPanel is possible, setting up SSR can be complex and requires advanced configuration.

Following these steps will help you set up and manage a Node.js application, along with popular frameworks, on cPanel.


Was this answer helpful?

« Back