Install node.js on Cpanel Server
- 15/11/2018 09:32
Using the steps below you should be able to quickly installÂ Node.jsÂ on your server, and begin testing commands directly on the server via the interpreter, or begin writing applications to run.
- Login to your server as the root user viaÂ SSH.
- You need to check for some software dependencies forÂ Node.js, as it requires OpenSSL, Python2.6+, and a compiler like gcc. You can check for these with the followingÂ yumÂ commands:
yum list installed | egrep "openssl-devel|python26|python27|gcc-c++"
You might get output back like this:
gcc-c++.x86_64 4.4.7-3.el6 @base
openssl-devel.x86_64 1.0.0-27.el6_4.2 @updates
On this particular server, we already have ourÂ gcc-c++Â compiler, and theÂ openssl-develÂ package installed. So we just need to install Python 2.6, or verifiy if it's already on the server and not installed viayum.
Check Python version or install Python 2.6
If you're on a newer VPS or dedicated server you should be running CentOS 6.x, you can confirm this by running the following command:
Which should return:
CentOS release 6.4 (Final)
Older servers would instead return something like:
CentOS release 5.9 (Final)
Now check your Python version with this command:
You should get back something like:
If you're on an older server, and your Python version is older than 2.6, run the following command to install Python 2.6:
yum install python26
If either theÂ gcc-c++Â compiler, or theÂ openssl-develÂ package were also missing when you checked, you'd run one of the following to install those dependencies:
yum install gcc-c++
yum install openssl-devel
- Now you want to navigate to your server's source directory:
- Grab the latest copy ofÂ Node.js:
- Extract theÂ Node.jsÂ archive:
tar zxvf node-latest.tar.gz
- Navigate to theÂ Node.jsÂ directory:
- Now finally configure and installÂ Node.jsÂ with this series of commands:
Upon a successful installation, the last few lines should look like this:
symlinking ../lib/node_modules/npm/bin/npm-cli.js -> /usr/local/bin/npm
updating shebang of /usr/local/bin/npm to /usr/local/bin/node
root@server [~]# node
> a = 3;
> b = 2;
> a + b;
(^C again to quit)
You should now have a successful installation ofÂ Node.jsÂ running, and in further guides we'll go more in-depth with some of the amazing things you can do withÂ Node.js!