{"id":216,"date":"2014-01-04T19:21:06","date_gmt":"2014-01-04T19:21:06","guid":{"rendered":"https:\/\/mellowhost.com\/blog\/?p=216"},"modified":"2016-01-28T11:40:38","modified_gmt":"2016-01-28T11:40:38","slug":"how-to-install-node-js-in-a-shared-cpanel-hosting-account","status":"publish","type":"post","link":"https:\/\/mellowhost.com\/blog\/how-to-install-node-js-in-a-shared-cpanel-hosting-account.html","title":{"rendered":"How to install node.js in a shared cpanel hosting account"},"content":{"rendered":"<p><strong>What is node.js?<\/strong><\/p>\n<p>Node.js is event-driven, asynchronous I\/O server-side JavaScript environment based on V8 engine.<\/p>\n<p><strong>Pre-Requirements<\/strong><\/p>\n<p>You don&#8217;t need full root access to install node.js in a cpanel hosting account. Although, you require to have access to the following from your hosting provider:<\/p>\n<p>1. Compiler Access<br \/>\n2. SSH Access<br \/>\n3. An open port<br \/>\n4. Automatic Process Killing Exclusion<\/p>\n<p>You need to first contact your provider to ensure you can access &#8216;1&#8217; &amp; &#8216;2&#8217;. In case 3 and 4, mention the port you want to use for your node.js app. Provider will exclude the port and your cpanel username in the firewall.<\/p>\n<p><strong>Installation: Step 1<\/strong><\/p>\n<p>First, find out if you have python 2.6 or above and bzip2-devel installed in the server. You can do using the following commands:<\/p>\n<p><code> # which python<br \/>\n\/usr\/bin\/python<br \/>\n# python -V<br \/>\nPython 2.6.6<br \/>\n# rpm -qa|grep bzip2-devel<br \/>\nbzip2-devel-1.0.5-7.el6_0.x86_64<br \/>\n<\/code><\/p>\n<p>Most of the latest cPanel server will have Python 2.6.6 or 2.6.7. So, as long as your provider isn&#8217;t running some old version of cPanel. If you have Python 2.6, you don&#8217;t need to recompile python. Python in cPanel server executable by the users. You might not see bzip2-devel installed. In case, it is not, your provider would need to install it using yum.<\/p>\n<p><code># yum install bzip2-devel<\/code><\/p>\n<p><strong>Step 2<\/strong><\/p>\n<p>Once the above &#8216;Step 1&#8217; things are available, you can download the latest node.js binary and compile it. While writing this tutorial, node.js is running 0.10.24. You can download the latest node.js source from here:<\/p>\n<p><a href=\"http:\/\/nodejs.org\/download\/\">http:\/\/nodejs.org\/download\/<\/a><br \/>\n<code><br \/>\n# wget\u00a0http:\/\/nodejs.org\/dist\/v0.10.24\/node-v0.10.24.tar.gz<br \/>\n# tar -xvzf node-v*<br \/>\n# cd node*<br \/>\n# .\/configure --prefix=$HOME<br \/>\n# make<br \/>\n# make install<\/code><\/p>\n<p>Out of all the commands above, you need to note the &#8216;prefix&#8217;. It should use $HOME if you are running from the user&#8217;s shell. A root user can use the path to the home directory of the cpanel user like \/home\/cpanelusername in place of $HOME to install node.js in a cpanel user&#8217;s account.<\/p>\n<p><strong>Step 3<\/strong><\/p>\n<p>If you have installed node.js from the root account, change the permission for \/home\/cpanelusername\/bin, \/home\/cpanelusername\/include, \/home\/cpanelusername\/lib to the cpanelusername.<br \/>\n<code><br \/>\n# cd \/home\/cpanelusername<br \/>\n# chown -Rf cpanelusername:cpanelusername node* bin include lib<\/code><\/p>\n<p>Now you can run a node.js node. A simple script to open a port can be the following:<br \/>\n<code><br \/>\n# nano sock.js<br \/>\n<\/code><br \/>\nInsert the following:<\/p>\n<blockquote><p>var net = require(&#8216;net&#8217;);<br \/>\nvar server = net.createServer(function (socket) {<br \/>\nsocket.write(&#8216;Open Serverrn&#8217;);<br \/>\nsocket.pipe(socket); });<br \/>\nserver.listen(674, &#8216;203.20.20.20);<br \/>\nconsole.log(&#8216;Server running at http:\/\/203.20.20.20:674\/&#8217;);<\/p><\/blockquote>\n<p>Now you can run the node as following:<\/p>\n<p><code># node sock.js<\/code><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is node.js? Node.js is event-driven, asynchronous I\/O server-side JavaScript environment based on V8 engine. Pre-Requirements You don&#8217;t need full root access to install node.js in a cpanel hosting account. Although, you require to have access to the following from your hosting provider: 1. Compiler Access 2. SSH Access 3. An open port 4. Automatic &hellip; <a href=\"https:\/\/mellowhost.com\/blog\/how-to-install-node-js-in-a-shared-cpanel-hosting-account.html\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to install node.js in a shared cpanel hosting account&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[33,12,21,25],"tags":[],"_links":{"self":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/216"}],"collection":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/comments?post=216"}],"version-history":[{"count":1,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/216\/revisions"}],"predecessor-version":[{"id":248,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/216\/revisions\/248"}],"wp:attachment":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/media?parent=216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/categories?post=216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/tags?post=216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}