How to Set Up a Node.js Application Using CloudLinux’s Node.js Selector in cPanel

If you are hosting your application on a server with CloudLinux installed and have access to cPanel, setting up a Node.js application becomes straightforward. CloudLinux’s Node.js Selector allows you to easily manage and deploy Node.js applications with various versions, without requiring advanced server configurations. Here’s a step-by-step guide to setting up a Node.js application using the Node.js Selector in cPanel.

Prerequisites

  • A cPanel account with Node.js Selector enabled by your hosting provider.
  • SSH or terminal access to execute commands (if necessary).
  • Your Node.js application code ready for deployment.

Step 1: Log in to cPanel

Log in to your hosting account’s cPanel. You can typically access cPanel by visiting yourdomain.com/cpanel and entering your credentials.

Step 2: Access the Node.js Selector

Once logged in, scroll down or use the search bar to find Setup Node.js App under the Software section.

Step 3: Create a New Node.js Application

  1. In the Setup Node.js App interface, click the Create Application button.

  2. You will be prompted to configure your application:

    • Node.js Version: Choose the version of Node.js you want to use for your application. Select the latest stable version that matches your app's requirements.
    • Application Mode: Select whether the application should run in Development or Production mode.
    • Application Root: This is the directory where your application files will be stored. You can either use an existing directory or create a new one.
    • Application URL: Define the URL path where your application will be accessible (e.g., https://yourdomain.com/app).
    • Application Startup File: Enter the name of the file that will start your application (e.g., app.js or server.js).
  3. Click Create once all the information is filled in. The system will now initialize the environment for your Node.js application.

Step 4: Upload Your Application Files

  1. Using the File Manager in cPanel or an FTP client, navigate to the Application Root directory that you defined in the previous step.
  2. Upload your Node.js application files into this directory.
  3. Make sure that your package.json file is correctly configured with the necessary dependencies and scripts.

Step 5: Install Dependencies

  1. Back in cPanel, return to the Setup Node.js App interface.
  2. Locate your application and click the Manage button.
  3. In the management interface, you will see an option to run the NPM Install command. Click this button to install the dependencies listed in your package.json.

Step 6: Start Your Application

  1. After the dependencies are installed, scroll down in the management interface and click the Run JS Script button next to the Application Startup File to start your application.
  2. You should see a message indicating that the application has started successfully.

Step 7: Test Your Application

Navigate to the Application URL you configured earlier. If everything is set up correctly, your Node.js application should be running live.

Step 8: Managing and Monitoring the Application

  • Restart Application: If you make changes to your code, you may need to restart the application using the Restart button in the Node.js Selector interface.
  • View Logs: To troubleshoot any issues, use the Error Log or Access Log options to view your application’s logs.
  • Change Node.js Version: You can easily change the Node.js version by stopping the application and selecting a new version in the setup interface.

Conclusion

Setting up a Node.js application using CloudLinux’s Node.js Selector in cPanel simplifies the deployment process significantly. By following these steps, you can quickly deploy, manage, and scale your Node.js applications directly from cPanel, without worrying about server configurations or manual installations.

With this setup, you’re now ready to develop and host Node.js applications with ease.

Was this article helpful?
YesNo