How to Set Up a Node.js App in cPanel

Here’s a detailed guide on How to Set Up a Node.js App in cPanel:


How to Set Up a Node.js App in cPanel

cPanel provides a feature that allows you to host and manage Node.js applications. This guide will walk you through the steps to set up a Node.js app using the Application Manager in cPanel.


Prerequisites

Before setting up a Node.js app, make sure you have:

  1. A hosting account that supports Node.js.
  2. Access to cPanel.
  3. The app's codebase ready for deployment (e.g., your app files in a .zip format or accessible via Git).

Step 1: Log into cPanel

  1. Open your web browser and go to your cPanel login page (usually yourdomain.com/cpanel).
  2. Enter your username and password to log in.

Step 2: Access Application Manager

  1. Once logged in, scroll down to the Software section in cPanel.
  2. Click on Application Manager.

Step 3: Create a New Application

  1. In the Application Manager, click the Create Application button located near the top-right corner.
  2. You will be presented with the configuration options for your Node.js app.

Step 4: Configure Node.js App

Fill in the following fields to configure your Node.js app:

  1. Node.js Version: Select the version of Node.js you want to use from the dropdown menu. Ensure this version matches the version required by your app.

  2. Application Mode: Choose between Production or Development mode. Use Production for a live app and Development for testing.

  3. Application Root: Enter the directory where your Node.js app files are located. This directory must exist in your hosting file system, such as public_html/yourapp.

  4. Application URL: Enter the URL where you want the app to be accessible, such as https://yourdomain.com/yourapp.

  5. Application Startup File: Enter the filename of your app’s main startup file (typically app.js, index.js, or as per your codebase).


Step 5: Upload App Files

You can upload your app files to the Application Root directory through File Manager or FTP:

  1. Navigate to File Manager in cPanel.
  2. Go to the directory you specified as the Application Root.
  3. Upload the necessary app files and folders (you can upload them in a .zip format and extract them, or use FTP to transfer the files).

Step 6: Install Node.js Modules (Dependencies)

  1. Once the files are uploaded, return to the Application Manager.
  2. Under the Actions section of your Node.js app, click on NPM Install. This will install all the necessary dependencies listed in your package.json file.
    • Make sure the package.json file is present in the Application Root directory.

Step 7: Restart the Node.js Application

  1. After installing the dependencies, go back to Application Manager.
  2. Under your app's Actions section, click on Restart to restart your Node.js app and apply the changes.

Step 8: Test the Application

Once the app is set up and running:

  1. Open a web browser and visit the Application URL you specified.
  2. You should now see your Node.js app running. If not, double-check the configuration, file paths, and startup script.

Optional: Setup Environment Variables

You can set environment variables for your app:

  1. In Application Manager, find your Node.js app and click on the Edit button.
  2. Scroll down to the Environment Variables section.
  3. Add any required variables by clicking Add Variable (e.g., PORT, DB_URL, etc.).
  4. Click Save after adding the variables.

Troubleshooting Tips

  • Startup File Issue: If the app isn’t starting, ensure the correct startup file is defined and located in the Application Root.
  • Port Conflicts: Most hosting providers do not allow custom port numbers, so your app might need to run on port 80 (for HTTP) or port 443 (for HTTPS).
  • Node.js Version: Ensure that the Node.js version you select matches the version required by your app.

Conclusion

By following these steps, you can successfully set up and run a Node.js application on cPanel using the Application Manager. This allows you to deploy your Node.js app in a shared hosting environment and manage it efficiently through cPanel.


 

  • Node.js, Node.js app setup, Node.js setup in cPanel, cPanel Tutorial, How to setup Node.js in cPanel
  • 0 Utilisateurs l'ont trouvée utile
Cette réponse était-elle pertinente?

Articles connexes

How to access webmail

To access the webmail use the following link: https://yourdomain/webmail Replace "yourdomain"...

How to access cPanel

The cPanel can be accessed via the following links: https://yourdomain/cpanel or...

How to increase Memory Limit & Maximum Upload size via php.ini

PHP Servers come with some default value for PHP configuration. To increase the memory limit or...

How to create an email forwarder

How to add forwarder:1. Login to cPanel2. Go to “Forwarders” link3. Click on “Add Forwarder”4....

How to add additional domain ( aka addon domain ) in cPanel

Please follow the steps:1. Login to the cPanel2. Go to the "Domains" link.3. Click on "Create a...

Powered by WHMCompleteSolution