How to Host Node JS Apps in cPanel
To deploy a Node.js application on your hosting, the initial step involves creating the application. You can achieve this by utilizing the user-friendly cPanel graphical interface. Simply navigate to the cPanel home screen, and under the "Software" section, choose "Set Up Node.js App.
To commence the application setup on the Node.js App page, simply click on the "CREATE APPLICATION" button.
Next, on the "CREATE APPLICATION" form, proceed to complete the required fields, which include:
On the "CREATE APPLICATION" form, you'll need to fill out the following fields:
-
Node.js version: Choose your preferred version from the dropdown list. (Latest version is recommended)
-
Application mode: Select either Development or Production from the list. You can initially choose Development and then switch to Production as needed.
-
Application root: This field indicates the location of application files in the file system. To form the full path to the application files in the cPanel home directory, the value will be appended to "/home/<username>/<applicationroot>".
-
Application URL: Use this field to create a web URL for your application.
-
Application startup file: Specify the very first file that the application will process once it has been launched.
-
Environment variables: This is a user-definable value that can affect the way running processes will behave within the application.
-
Create Application:
- After completing the form, click on the "CREATE" button.
- Once the application is successfully created, it will start automatically.
-
Stopping the Application:
- To stop the application, click on the "STOP APP" button.
- Upload all your Node.js application files to the application root using the File Manager.
-
Installing Dependencies:
- Return to the Node.js App page.
- To install dependencies, click on "Run NPM Install."
- After a successful installation, proceed to start the application again.
-
Starting the Application:
- Click on the "START APP" button to relaunch your application.