I have working on something on top of node.js and wanted to install on my hosting account. There are many tutorials available on this topic but they have some or the other thing incomplete. Hence I decided to combine all of them together and post here a working solution.

1. Create the directory to store the Node binaries

mkdir -m 755 node creates the folder used to store the Node.js binaries

2. Download & Compile Node.js

wget http://nodejs.org/dist/v0.8.0/node-v0.8.0.tar.gz
tar -xvf node-v0.8.0.tar.gz


Because Hostmonster are shared server we need to specify where to have the Node.js binaries stored

cd node Bring us to the Node.js source files
/configure —prefix=/home/{username}/node
make && make install

Replace {username} with your login name for Hostmonster. You can find your username in the cPanel on the left where it says username.

3. Now we need to make the node command usable so do the following commands

cd ../.. puts us back at the root of our home folder

cd ../..
nano .bashrc

4. Now add the following line to the bottom of the file.

export PATH=/home/{username}/node/bin:$PATH

Replace {username} with your login name for Hostmonster. You can find your username in the cPanel on the left where it says username.

5. Save

ctrl+x confirm save by typing ‘Y’ then enter, then enter again to confirm the file.

6. Lets verify that everything is working. You will need to reload bash

source .bashrc

7. Now verify that node is installed and running

node —version

Update:

To Start Node.js can be found here http://www.nodejs.org/ but for an internet user to access it you will need a dedicated ip address and the port open.

In most cases it would be something to similar:

node server.js

If you do not have a static ip address on hostmonster then it would be difficult to reach the nodejs server on the hosting account as the ports are blocked. The workaround would be to use a php proxy script to relay the information from nodejs server.

Comments
  1. Eduard Ruzga says:

    Hi, was trying to install node.js on hostmonster using your guide. Sadly it fails somewhere at install stage with this:
    mkdir -p /usr/local/include/node/
    mkdir: cannot create directory `/usr/local/include’: Permission denied

    make: *** [install] Error 1

    Apparently its rights related and usually people suggest to use sudo to fix that but its not available for hostmonster users.
    Hmm, did you had similar issues?

    • dilberted says:

      Did you run
      . /configure -prefix=/home/{username} /node

      This will make sure that ur node installation will go under this directory..

      • Eduard Ruzga says:

        Thanks for such quick replay.
        And I use {username} in my examples but I did change it to my real username when I was doing it so mistake probably is not there.

        So. For me this from your article:

        ——————————————————–
        /configure —prefix=/home/{username}/node
        -bash: /configure: No such file or directory
        ——————————————————–

        while this:

        ——————————————————–
        ./configure -prefix=/home/wonderwh/node
        Usage: configure [options]

        configure: error: no such option: -p
        ——————————————————–

        Though when I copy-paste,
        — turns in to .
        and result is here:

        ——————————————————–
        ./configure .prefix=/home/{username}/node
        { ‘target_defaults’: { ‘cflags’: [],
        ‘default_configuration’: ‘Release’,
        ‘defines’: [],
        ‘include_dirs’: [],
        ‘libraries’: []},
        ‘variables’: { ‘host_arch’: ‘x64’,
        ‘node_install_npm’: ‘true’,
        ‘node_install_waf’: ‘true’,
        ‘node_prefix’: ”,
        ‘node_shared_openssl’: ‘false’,
        ‘node_shared_v8’: ‘false’,
        ‘node_shared_zlib’: ‘false’,
        ‘node_use_dtrace’: ‘false’,
        ‘node_use_etw’: ‘false’,
        ‘node_use_openssl’: ‘true’,
        ‘strict_aliasing’: ‘true’,
        ‘target_arch’: ‘x64’,
        ‘v8_use_snapshot’: ‘true’}}
        creating ./config.gypi
        creating ./config.mk
        ——————————————————–

        So after that last result I tried to do make and make install but I guess its wrong…
        Probably I am doing something stupid as its first time I need to use ‘configure’ like this.
        So I am doing something wrong with prefix it seems as it tries to install to default location to which in my case I have no access.
        Any ideas what I am doing with with configure?

        Really thanks!

      • Eduard Ruzga says:

        Ok I think I found what’s wrong. — should be —

  2. Ben Rolfe says:

    Thanks for the helpful guide!
    I also had an permissions error during ‘make install’. For me, the solution was to change ‘home’ to ‘home2’ in the configure line.

    I won’t pretend to understand what’s going on here, but a quick test people can try is this:
    cd /home/{username}

    If you end up at
    {username}@{domain} [/home/{username}]#
    instead of
    {username}@{domain} [~]#
    then try
    cd /home2/{username}

    If that takes you to [~], then replace ‘home’ with ‘home2’ in the above instructions and all should be well. Otherwise, um, maybe try home3??

    • dilberted says:

      Another way to find out the path would be by logging in to the cPanel and on the left side of the panel where server information is displayed you would be able to see the path as well. 🙂

Leave a comment