Node.js Application on Ubuntu Linux box


You may have worked on windows all your life and one fine day you come across the need to deploy your node.js application on Linux flavors  You have no clue what commands to use or what to do. If you are this guy, then read ahead and by the end of this post you will know how to deploy on Linux. 
Those who wish to deploy on a local Linux host can skip the next two sections and head to section 3.
Pre-Requisites for deploying to a remote host:
1)      We need a TELNET/SSH agent such as MTPUTTY to communicate to the remote box
a.       Please download the Multi Tab Putty from this site and run the installer: http://www.softpedia.com/progDownload/MTPuTTY-Download-195361.html
b.      Download the Putty.exe from this site http://www.softpedia.com/progDownload/PuTTY-Download-1001.html
c.       Under the root installed directory of the Multi Tab Putty, create a folder called “putty config” and place the putty.exe from step (b) here.



2)      Configure server
a.       Click on the MTPUTTY short cut key from desktop.
b.      Click on “add server icon”
c.       On the Properties popup,
                                                       i.      enter the server name ie linux server IP,
                                                      ii.      Select SSH protocol for secured connection,
                                                    iii.      enter the port as 22,
                                                    iv.      enter the Display Name of your choice.
                                                     v.      Enter the username and password created on the Linux box for your user profile.
                                                    vi.      Click on Ok
d.      
e.      Now on the server created, double click on the left tab.
f.        And you are good to go if you have logged in successfully without any error popups.
3)      Update the Linux Box:
a.       In the putty console/local console à run the following command: “sudo apt-get update” . This command downloads all the latest versions of the packages and synchronises them.
b.      Next install the GIT followed by SSL support packages. “sudo apt-get install git-core curl build-essential openssl libssl-dev”
4)      Node Installation
a.       Create any directory of your choice, say under /opt/application/install/
b.      You can create a dir using mkdir <dirname> and remove using rm <dirname>
c.       Under the folder of your choice, clone the repository of the node.js as follows:
                                                       i.      “git clone https://github.com/joyent/node.git
                                                      ii.      “ls –la” , you should see the directory created – “node”
                                                    iii.      “cd node”
                                                    iv.      “git tag” provides all the versions of node available on a given date
                                                     v.      eg :   “git checkout v0.8.14” will check out a specific version of the node.
                                                    vi.      Compile the code:
1.        “./configure”
2.       “make”
3.       “sudo make install”
4.       Run “node -v” to see of you obtain the version of the node.
5)      Install NPM:
a.       Install NPM using : “curl http://npmjs.org/install.sh | sudo sh”
b.      Check if you have the latest version using : “npm -v”
c.       NPM will let you install node modules with ease.
6)      Creating the Node Application:
a.       Please read my post here if you are unaware to create a simple node application.
7)      Starting the Node Application On Ubuntu Linux:
a.       Assuming you have a node application created, traverse under the root directory of the application, hit “node app.js” and you can access this on the browser and view the application running.
8)      Smart deploy existing Application from Windows
a.       If you have an existing application on Windows use Filezilla and do the transfer to the remote host.

Hope this article helps you out in your first venture to deploy a node.js application on Ubuntu.

3 comments:

  1. Here is a great guide about how to install Node on a Linux machine.
    https://www.rosehosting.com/blog/how-to-install-nodejs-bower-and-gulp-on-debian-8/

    ReplyDelete
  2. It is a really Very good blog! Thanks for sharing content and such nice information.I hope you will share some more content.Please keep sharing
    Node JS Online training
    Node JS training in Hyderabad

    ReplyDelete