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 Node.js
and NPM
.
Prerequisites
- Your hosting account must have
SSH
(not jailshell) enabled. To check whichshell
your account is using, login yourSSH
account and type the following command:
|
|
Node.js
currently only works on servers running CentOS 6 or CentOS 7. To check the version of CentOS on your server, log in to your account usingSSH
, 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
Node.js
andNPM
(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
nodejs
name, type this command:
|
|
- To install the
node
andnpm
binaries, type these commands (may not be a required step in your setup):
|
|
- After you run these commands,
Node.js
andNPM
are installed on your account. To verify this, type these following commands:
|
|
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.
Create a server.js
file on local, and upload it to the subdomain directory.
server.js
|
|
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.
GET http://services.zeptobook.com:49500/
This is how, you can setup Node.js and NPM on your linux server.
Summary
In this blog, we learned about setting up Node.js and NPM on Linux hosting server.