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.