All our Shared Hosting servers are equipped with NodeJS, they can be managed by either cPanel or Cloudlinux, below we will go into both ways of deploying an NodeJS app in our environment.
NodeJS on CloudLinux
At OrangeWebsite all of our shared servers come equipped with NodeJS supported by the Cloudlinux environment, thus we support all available versions they support, see the image below:
(The versions change based on CloudLinux support automatically)
How to Deploy a Node.js app using Cloudlinux
Below is an example of how to deploy a Node.js application in your Shared Hosting plan via cPanel.
- Now that we are logged into our cPanel, let’s click the Setup Node.js App icon under Software.
- Once we’re inside we can start by clicking the Create Application
- Now comes the important part, where we are going to place our application, what root directory will it reside in and what is the full path to it, it’s important to know that you do not have to generate the app.js yourself, all you need to decide is 2 parameters, the directory, and the URL. In our example below, I am placing the application in my
/public_html/myapp
Application root: /public_html/myapp
Application URL: [mydomain.tld]/myapp
(NOTE: If you create a Subdomain first, you can always set the application root to just “myapp” and the application url to the subdomain directly, this would create the application in your subdomain)
When you are ready, click Create and you are done creating the application. - We can verify the app is properly created in our cPanel > FileManager (see image below)
So far so good. - Now that we can see it works, we can see in the Setup Node.js App when we look at the image below, the application is running, it’s set to Development mode, you u can set this to Production when ready.
Of course, this is just a basic app, now you need to create a package.json file if you wish to add using the Run NPM Install to create a so-called “node_module” folder with all the required modules to run in your app, but that is outside the scope of this article. - To test if your node application works, click the Open button next to the Application URL and you should see something like this (see image below)
If you do see something like this, you have successfully created a nodeJS-based app.
Read more about the package.json creation part here:
Creating a Package JSON File
Deploying a Node.js Application in cPanel on a Subdomain
That is all!.
How to Deploy a Node.js app using cPanel
If you are here because you would like to deploy a Node.js application on your own non-CloudLinux server, a standard AlmaLinux-based server, there is a guide on cPanel extensive on how to do so here.
How to Install a Node.js Application
It’s important to know, to use this method, you need your own cPanel server with root access, and you need to be able to install all required requisites. There is not much we can write about this as cPanel covers this in much greater detail.