Back to Blog
Tutorials

How to Host a Node.js App on cPanel: Step-by-Step Guide

Learn how to host your Node.js app on cPanel with this easy step-by-step guide. From setting up your hosting with HahuCloud to configuring and deploying your app, we’ve got you covered!

3 min read
Share:
How to Host a Node.js App on cPanel: Step-by-Step Guide

Hosting a Node.js app on cPanel is an excellent way to take your application live and make it accessible to users. Whether you're a beginner or an experienced developer, this guide will walk you through the process of setting up and hosting a Node.js app using cPanel. Let's get started!


Step 1: Get Your Hosting Account Ready

Before diving into the technical steps, make sure you have a cPanel hosting account. At HahuCloud, we provide hosting plans that support Node.js applications with all the features you need.

If you don’t already have an account, visit HahuCloud, select a hosting plan, and complete your purchase. Once your account is ready, log in to your cPanel dashboard to begin the setup process.


Step 2: Create Your Node.js Application

To host a Node.js app, you’ll first need to create an application within cPanel:

  1. In your cPanel dashboard, locate the SOFTWARE section and click on the Setup Node.js App icon.

  2. On the Node.js selector page, click CREATE APPLICATION to start configuring your app.

  3. Fill out the application setup form:

    • Application Root: Enter the directory where your app will reside (e.g., /app).

    • Application URL: Provide the desired URL (e.g., example.com/app).

    • Application Startup File: Specify the file that will serve as your app’s entry point (e.g., app.js).

  4. Click CREATE to finalize the setup.

Your application will start automatically. To test it, click OPEN or visit the application URL you specified. You should see an “It Works!” message.


Step 3: Create a package.json File

The package.json file defines your app’s dependencies and configuration. Here’s how to set it up:

  1. In your cPanel, open the File Manager.

  2. Navigate to the root directory of your application.

  3. Click +File to create a new file and name it package.json.

  4. Open the file and add the following code:

Save the file once you’ve added the code.


Step 4: Add Your Application Files

With the package.json file in place, you can now add the rest of your application files:

  1. Upload your Node.js files (e.g., app.js) to the application root directory you specified earlier.

  2. Use the cPanel Terminal or an FTP client if you prefer to upload multiple files more efficiently.


Step 5: Install Dependencies

Next, install the dependencies for your Node.js app:

  1. Return to the Setup Node.js App page in cPanel.

  2. Under the application list, click run npm install. This will install the dependencies defined in your package.json file.


Step 6: Start or Restart Your Application

After installing dependencies, you may need to restart your application:

  1. In the Setup Node.js App section, locate your app under the application list.

  2. Click Restart to ensure everything is running smoothly.


Step 7: Test Your Application

To verify your app is working, open your application URL (e.g., example.com/app) in a browser. If everything is set up correctly, you’ll see your app live and functioning!


Why Host Your Node.js App with HahuCloud?

At HahuCloud, we make hosting Node.js apps simple and reliable:

  • Node.js Support: Fully compatible with Node.js applications.

  • Secure Environment: Enjoy SSL certificates and robust security.

  • Easy Setup: cPanel simplifies the deployment process.

  • Expert Support: Our team is ready to assist you whenever you need help.


Conclusion

Hosting a Node.js app on cPanel is a smooth process when broken into steps. By setting up your hosting with HahuCloud, creating your app, and configuring it correctly, you can take your Node.js application live in no time.

Ready to host your app? Visit HahuCloud to get started today!

Y

Written by

Yared