Press "Enter" to skip to content

6 Steps to Host Node.js Application in Shared Hosting

Node.js is an open-source, runtime environment used for developing highly scalable networking and server-side applications. It is grounded on event-driven, I/O model. This model makes node js is lightweight and efficient.

Node js used for building highly accessible server-side Java-Script applications such as web application, command-line application, real-time chat application, etc. However, node js is also used to design network-based programs such as web servers, similar to PHP, ASP.NET, and Java, etc.

Most of the web hosting provider does not support to install node js hosting India services. The web hosting provider generally provides PHP preinstalled on your web server.  When you are going to host a node.js application in a shared hosting server then the first thing that you have to do is to install NVM on your web server. For that NVM installation, you need to log in with SSH from your terminal (command line). 

Step 1

node.ks application
  • You can create an SSH Key from your cPanel account and after that, you can access your web hosting account from your Terminal.
  • To access SSH of your server you should ask your host provider.

ssh -p port username@IpAddress

After that it will ask you for your password, then you should enter the password that you normally used to login to your cPanel account. Once you enter the password at that time you have done with the first step.

Read also:   3 Best Methods to Create a SQL Server Backup

Step 2: Installation of the NVM on your web server.

  • Once you successfully login through ssh, then you are able to access all Linux commands.
  • Run the following command to install NVM

wget -qO- https://cdn.rawgit.com/creationix/nvm/master/install.sh | bash

Step 3

After that run following command:

nvm install stable

Step 4

  • Once you have done with NVM installation, now close and reopen the terminal where you are going to run the ssh. Now you need to log in again the same way that you logged in the first time.
  • To run node js on the server you need to confirm that node and npm have been successfully installed on the server or not. The above command is used to check whether Host a Node.js Application in Shared Hosting or not.
  • Run the following command:

node -v
npm -v

  • After that copy and paste the below command into the file

RewriteEngine On
RewriteRule ^$ http://127.0.0.1:XXXXX/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:XXXXX/$1 [P,L]

  • Now you need to replace the code XXXXX with your port no that you have set in your app.

Step 5

When you want to host a node.js application in shared hosting at that time you need to upload your project on the hosting server and now you able to run node js on server.

  • Now run the node js application in the same way that you normally run on your local server.
  • Run node app.js or node server.js, just in a normal way that you would do it locally.

Step 6

  • When you are going to reload the websites with domain names, then you need to load the page correctly. But in between the page load if you press “control C” on the terminal you will kill the server and page load will not perform again.
  • This is a perfectly normal process, it means that your server should run continuously after exiting the terminal also. You can do that by just using
Read also:   How to Use Call Recording App to Monitor Your Kids

node app.js &

The above command will run node js on the server even after you exit the terminal. You can also do this by using a more efficient way, you can install the following package that takes care of that

npm install -g forever

Then start the server.

forever start app.js

And now you have successfully hosted a node.js application in shared hosting.

cPanel support Node.js?

Now recently you can install node.js on cPanel. cPanel provides support for node js applications. It is easy to install node js on a shared hosting server by using cPanel. You can do this installation very quickly by simply log in to your cPanel account and click on the “Setup Node.js App” icon and now click on the “Create application” button.

How to select Best Node.js Hosting?

When you are going to host a Node js app on the shared host then there is a need to choose the cheapest web hosting provider that provides free or fewer charges to install node js on shared hosting with the following features. You should check the following features while looking for the best web hosting for your website with free node js installation.

Features You to Look For:

Some additional features that you should look to host a node.js application in shared hosting:

  • Full SSD storage
  • Security Tools
  • Use of CDNs to improve website performance
  • Use of SSL Certificate
  • High Speed + Uptime guarantees
  • Choice of data canters

By considering all these features, you can select your best web hosting provider and can host a node.js application in shared hosting.

Read also:   QuickBooks error 404: Causes and How to Resolve it
6 Steps to Host Node.js Application in Shared Hosting 1

Be First to Comment

    Leave a Reply