In the last few months Node.js has been picking up in popularity. You see it on Twitter, you see in on Hacker News, so why haven't you tried it yet?
For me it was because Cygwin on Windows was a bit nebulous. Even if you're on OSX, the process might have been too much of a hassle.
Well be excused no more because I made an Amazon EC2 AMI
(community AMI ami-d7451792, US West region) loaded with the Node basics. Node.js, npm, express, NowJS all come pre-installed, pre-configured, and ready to use!
Why EC2
For new customers Amazon is giving away a whole year of dedicated hosting on their micro instance. Even if you're not a new customer, it's only $0.02 an hour. So let's get started javascripting!
If you're already familiar with EC2, read the TLDR
If you're new to EC2 or want extra guidance getting your instance setup, continue reading
Step-by-step: Setting up a FREE or $0.02/hr EC2 Micro instance with Node.js
Step 1: Get a EC2 account
Step 2: Enter the AWS Management Console. Choose the "US West region" and click "Launch Instance"
Step 3: In the `Request Instance Wizard` click `Community AMIs` and search for `ami-d7451792`. Click the Select button
Step 4: Choose the `Micro` instance size to take advantage of the free tier. Click continue
Step 5: Leave the two `Instance Details` page as their defaults and click Continue
Step 6: Now you need two create an SSH keypair
If you're not familiar with SSH, this might sound intimidating but it really isnt. In order to connect to your new server, you will be using SSH to communicate. SSH with EC2 requires that the server have your `public key` and you have the `private key` with these two pieces, you can authenticate and login to your server. We're going to generate a public/private keypair now.
This will spit out a .pem (a security certificate file) file for you. This is your private key! Keep it in a safe place
(Important: If you're planning on using PuTTY for your SSH client, you're going to have to convert that .pem to a PuTTY compatible .ppk! )
Then click continue
Step 7: Configure the Firewall
Just for testing purposes, lets open all the ports. Don't tase me bro.
Step 8: Review settings & Click Launch!
After you click launch, many magical things will happen at the Amazon datacenter. Jigahertz are traveling through tubes and somehow an instance matching exactly what you've told the wizard is booting up!
Step 9: Find out the server's hostname
After the server is done loading, the `public dns` will show up, thats the address to your shiny server!
Step 10: Connect to your server!
If you're on an unix system, go to your terminal and do something like this:
`ssh -i mykeypair.pem ec2-user@myec2serveraddress.compute.amazonaws.com`
If you're on PuTTY
Step 10: Lets run the example
Since Node, express, Now.js are already installed, lets run the NowJS chat example:
When you have established the SSH connection,
`cd examples`
`node helloworld_server.js`
That's it! Now you have a Node.js server running with the NowJS example chat server (on port 8080).
Navigate with your browser to `http://myec2serveraddress.compute.amazonaws.com:8080` to see it.
If the page won't load, you probably forgot to open the right ports in the firewall ("security group") step of launching the instance.
Now you're ready to hack on Node.js!!!! If you have any difficulty,
Try the #node.js irc channel or #nowjs irc channel, both on Freenode.
TLDR (If you're familiar with EC2);
Simply launch an EC2 instance for community AMI
ami-d7451792, US West region and you'll be up and running
Try cd'ing into the `examples` folder, and running `node helloworld_server.js`. Then go to `http://myec2serveraddress.compute.amazonaws.com:8080` to try out the chat example.
More about NowJS
NowJS makes real-time applications easier to develop by synchronising functions and variables in a namespace between clients and a server.
http://nowjs.com