How to Install node.js on a cPanel Server
- Category : Linux Helpline (Easy Guide)
- Posted on : Mar 27, 2019
- Views : 3,549
- By : Ingavar J.
Installation of node.js is not yet officially supported by cPanel.However It’s still a feature request .
(Discussion at Official cPanel Forum too )
What is Node.Js?
Node.js is an application development software written in and for javascript for real-time event-driven applications,more at http://en.wikipedia.org/wiki/Node.js
The Installation Procedure:
Installing node.js on a cPanel VPS doesn’t involve any complex tasks. Prior beginning the installation make sure following requirements are met:
GCC 4.2 or newer
Python 2.6 or 2.7
GNU Make 3.81 or newer
Run and Update for any software in the above list (If not up to date).
Initially download latest version from nodejs.org .
wget http://nodejs.org/dist/v0.11.9/node-v0.11.9.tar.gz
Next, extract the node.js tarball and install it:
tar -xzvf node-v0.11.9.tar.gz cd node-v0.11.9 ./configure make && make install
The installation will take a while to complete . Now upon completion we could test it working.Check the version
[root@sh csf]# node -v
v0.11.9
[root@sh csf]# which node /usr/local/bin/node [root@sh csf]# /usr/local/bin/node --help
Usage: node [options] [ -e script | script.js ] [arguments] node debug script.js [arguments]
Options: -v, --version print node's version -e, --eval script evaluate script -p, --print evaluate script and print result -i, --interactive always enter the REPL even if stdin does not appear to be a terminal --no-deprecation silence deprecation warnings --trace-deprecation show stack traces on deprecations --v8-options print v8 command line options --max-stack-size=val set max v8 stack size (bytes)
Environment variables: NODE_PATH ':'-separated list of directories prefixed to the module search path. NODE_MODULE_CONTEXTS Set to 1 to load modules in their own global contexts. NODE_DISABLE_COLORS Set to 1 to disable colors in the REPL
Documentation can be found at http://nodejs.org/
Testing the Installation:
Just scroll to cd /usr/local/cpanel/htdocs
vi server.js
var http = require("http"); http.createServer(function(request, response) { response.writeHead(200, {"Content-Type": "text/plain"}); response.write("Hello Test"); response.end(); }).listen(8080);
save and quit
Open the port 8080 in your firewall via csf conf .
vi /etc/csf/csf.conf
TCP IN, OUT ===>8080
save and quit
csf -r
(from the dir/usr/local/cpanel/htdocs execute below ) /usr/local/bin/node server.js Now access http://ip.add.re.ss:8080
You will get a confirmation message in your browser that says “Hello World”.
Extra:
If you need to direct traffic for our domain to the node.js build, you could implement it using via the .htaccess file by following rules.
RewriteEngine on RewriteCond %{HTTP_HOST} ^domain\.com$ [OR] RewriteCond %{HTTP_HOST} ^www\.domain\.com$ RewriteRule ^(.*) "http\:\/\/127\.0\.0\.1\:8080\/$1" [P,L]
Your domain name replaces “domain” in the above example. Just visit your domain again!
The above installation is tested under latest cpanel .
[root@sh]# cat /usr/local/cpanel/version 11.44.1.19 [root@sh]#
Let us know whether any sort of change or modification is needed for above installation, suggestions are invited!
Categories
- cPanel Question 47
- cPanel Software Management 29
- cPanel Tutorials 13
- Development 29
- Domain 13
- General 19
- Linux Helpline (Easy Guide) 156
- Marketing 47
- MySQL Question 13
- News 2
- PHP Configuration 14
- SEO 4
- SEO 42
- Server Administration 84
- SSL Installation 54
- Tips and Tricks 24
- VPS 3
- Web Hosting 44
- Website Security 22
- WHM questions 13
- WordPress 148
Subscribe Now
10,000 successful online businessmen like to have our content directly delivered to their inbox. Subscribe to our newsletter!Archive Calendar
Sat | Sun | Mon | Tue | Wed | Thu | Fri |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
Recent Articles
-
Posted on : Sep 17
-
Posted on : Sep 10
-
Posted on : Aug 04
-
Posted on : Apr 01
Tags
- ts
- myisam
- vpn
- sql
- process
- kill
- tweak
- server load
- attack
- ddos mitigation
- Knowledge
- layer 7
- ddos
- webmail
- DMARC
- Development
- nginx
- seo vpn
- Hosting Security
- wireguard
- innodb
- exim
- smtp relay
- smtp
- VPS Hosting
- cpulimit
- Plesk
- Comparison
- cpu
- encryption
- WHM
- xampp
- sysstat
- optimize
- cheap vpn
- php-fpm
- mariadb
- apache
- Small Business
- Error
- Networking
- VPS
- SSD Hosting
- Link Building
- centos
- DNS
- optimization
- ubuntu