Node.js is a popular, event-driven JavaScript runtime where you can use to build robust web applications. If you are already familiar with creating node.js apps, you may be wondering how to get your app onto a shared server. In this article, I explain how to host a node.js application in cPanel.
To deploy node.js application on hosting, firstly you have to create the application. You can create application using cPanel graphical interface by selecting Setup Node.js App under Software section of cPanel home screen.
Now click CREATE APPLICATION to begin the application setup on the Node.js App page:
Then on the CREATE APPLICATION form, 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. One may initially choose Development and then switch to Production.
- Application root: It is for 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: It is to form a web URL of the application.
- Application startup file: 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 on a application.
Click CREATE after finishing the form. After created successfully an application starts automatically. Then, click STOP APP to stop the application and upload your all node app files on application root from File Manager. Now, you need to back on Node.js App page for install dependencies. For install dependencies, click Run NPM Install. After successful installation, click START APP to start again the application.
Now "It works!"
If you want to run MongoDB with your node app, then you need to open port 27017 for your hosting by creating a support ticket.
Top comments (2)
Keep going vaiya
great