This blog will show, how to setup Node.js and NPM on your managed hosting server. We are going to host in Linux server.
Before moving forward, please keep your SSH credentials in hand. We are going to use
SSH tool to install
- Your hosting account must have
SSH(not jailshell) enabled. To check which
shellyour account is using, login your
SSHaccount and type the following command:
Node.jscurrently only works on servers running CentOS 6 or CentOS 7. To check the version of CentOS on your server, log in to your account using
SSH, and then type this command:
If the output from this command contains el6 (for example, 2.6.32-531.17.1.lve1.2.60.el6.x86_64) or el7 (for example, 3.10.0-714.10.2.lve1.5.12.el7.x86_64) , then your server is running CentOS 6 or CentOS 7.
However, if you see el5h (for example, 2.6.32-531.23.3.lve1.2.66.el5h.x86_64), then your server is running CentOS 5 and does not support Node.js. Please contact your hosting provider.
Installing Node.js and NPM
- After your account meets the installation prerequisites, you can download and install
NPM(the Node.js package manager). To do this, follow these steps:
This will save node.js package on your server directory.
- To extract the Node.js files, type this command:
- To rename the extracted folder to the more convenient
nodejsname, type this command:
- To install the
npmbinaries, type these commands (may not be a required step in your setup):
- After you run these commands,
NPMare installed on your account. To verify this, type these following commands:
The ~/bin directory is in your path by default, which means you can run node and npm from any directory in your account.
Creating your Node.js application on server
After successful installation of Node.js and NPM on your service, next step is create a node.js application. So, I have created a subdomain
services.zeptobook.com, and put the node.js app there.
server.js file on local, and upload it to the subdomain directory.
Now, go to SSH terminal, and go to your subdomain directory, and run this command.
Now, go to the PostMan tool, and access your service url.
This is how, you can setup Node.js and NPM on your linux server.
In this blog, we learned about setting up Node.js and NPM on Linux hosting server.