Node.JS Up And Running In The Cloud – on Amazon EC2

I got the information for this post from another blog post by Kostas Mavropalias, which was super helpful and insightful. All credit to him!

It’s not much good if I can only build and test node locally. Deploying to the web is an integral part of development. For Node.JS the options are a little tricky as of today. Services such as Nodejitsu are cool and have their perks, but there are limitations such as being an invitation-only beta and the trade-off of black-box platform-as-a-service deployment. Hosting companies, even excellent ones such as Dreamhost, don’t allow you to run background processes such as Node unless you pay for premium services.

The solution I’m liking so far is using a micro-instance on AWS EC2. For the sake of brevity, this post will assume that you already have set up an AWS account, have launched an EC2 Linux instance, and have shell access to said instance. In a later post, I plan on going over that process step-by-step. For now, we’ll begin from the terminal, having SSH’d into our instance.

First we run the basic updates:

[gist id="2957236" file="01-Initial-Updates.txt"]

Next we clone the Node build files and run the installer. The “make” step can take twenty or more minutes to complete.

[gist id="2957236" file="02-Git-And-Node.txt"]

Once we’ve installed Node, we have to make it accessible to all users using sudo commands.

[gist id="2957236" file="03-Making-Node-Available.txt"]

Now that Node is globally available to us from the terminal prompt, we need to install our package manager, NPM:

[gist id="2957236" file="04-Install-NPM.txt"]

Lastly, you should install all of the node modules and packages that you’ll need for regular use. Of particular importance is Forever. This is what will allow us “set-it-and-forget-it” execution of Node processes so as to have a “real” server!

[gist id="2957236" file="05-Node-Packages-To-Install.txt"]

Now our EC2 instance has a full Node.JS capabilities, congrats! My suggestion is to make yourself an AMI of the machine in this state from the AWS console so that you can quickly boot up to this point when testing projects in the future, it will save you the build time and headache.

Reboot

Hi, I’m Kit Phelps and I like making software on the web. It’s been awhile since the last major overhaul to my webpage, and I figure if Batman and James Bond can pull off a reboot, so can this simple portfolio page.

I’m currently enjoying my days as a product manager with an ed-tech start-up Late Nite Labs in the heart of New York City. There’s a tremendous team over there and I hope to be able to share some technical insights for some of the fun things we’re putting together.

In my spare time I’ve been digging into Node.JS (particularly multi-user functionality via websockets in Socket.IO) as well as some native iOS programming.