Read more of this story at Slashdot.
In 2o09 I wrote a tutorial called EC2 for Poets, and updated it in 2012.
The goal of this project was to see if it was possible to teach intelligent computer users to set up and run a server. The project was a success. Pretty much anyone who wanted to do it was able to. I felt that setting up a server was no more complex than learning how to use PhotoShop (something I have never mastered) or a spreadsheet.
However EC2 was not designed for this. If it were it could have been a lot simpler.
Lately I've become interested in Node.js. I've learned how to write Node apps, and have a couple of simple ones running, and doing things for me and some of courageous users.
And the question comes up -- how easy is it to set up a Node server?
The answer -- pretty easy, once you know how to.
So that's what I'd like to do now. Tell you how to do it.
With the caveat that I've just learned myself, with the expert and patient guidance of a longtime friend -- Eric Kidd. He's really the author of these instructions, I've just tested them and written them down.
#### You're using a Mac, I hope
I'm writing these instructions assuming you're using a Mac. It'll work similarly if you're using Linux, and I'm told there are some small differences if you're on Windows. I haven't tried it there.
#### Before starting
Create an account on heroku.com. In this regard it works like every other site, so I won't insult your intelligence by giving you detailed instructions for this part of the experiment.
#### Launch Terminal
In the Applications folder, there's a program called Terminal. Launch it. This is how you communicate with Heroku from your computer.
Install git.
Install the Heroku toolbelt. Follow the instructions on the Heroku site.
#### Get my example app
I have a simple Node app called fargoPublisher. Download the project using this link. Unzip it. Change the name of the folder to fargoPublisher.
It doesn't matter where you put the folder, but we're going to have to refer to it later, so let's assume you put it on a disk named myworld.
#### Name your app
You need to come up with a unique name for your app, one that isn't used elsewhere in Heroku. It could be a little tricky, but you'll get an error message if you choose one that someone else is using. In the instructions below, I use the name purplenutter.
#### Magic incantations
Type these commands in the Terminal app, exactly as they appear here.
cd /myworld/fargopublisher
git init
git add package.json counters.js
git commit -m "Initial source code"
heroku create purplenutter
#### Did it work?
If it worked you should get a confirmation message from Heroku.
And your app, if it was named purplenutter, will be at http://purplenutter.herokuapp.com/.
#### Setting environment variables
There's one more step to getting the app running for real, if you want to, you have to set a couple of environment variables so that it can write to your S3 bucket instead of mine (assuming you have an Amazon account).
There are four variables you have to set: the AWS access key ID, and secret access key, the path to a folder in one of your buckets, and a domain name. To test out whether the app is running you don't have to supply real values, just something -- so the program can access them.
You set an environment variable like this:
heroku config:set AWS_ACCESS_KEY_ID=OHBEAUTIFUL --app purplenutter
heroku config:set AWS_SECRET_ACCESS_KEY=FORSPACIOUS --app purplenutter
heroku config:set fpHostingPath=/mybucket/users/ --app purplenutter
heroku config:set fpDataPath=/mybucket/data/ --app purplenutter
heroku config:set fpDomain=helloworld.com --app purplenutter
Enter each of these commands into the Terminal app.
Each time you do it, your app will restart.
#### The proof it's running
Enter this into your browser, substituting the name of your app:
http://purplenutter.herokuapp.com/version
You should get back a number, something like 0.59. If so -- it's running!
You should also visit your app on the Heroku site. To do so, go to the Apps page, and click on the link to your app. You're such a geek! A successful one! :-)
#### What if you make a change?
No app is ever finished, you'll want to add features, fix bugs.
When you've made a change, here's the prayer you need to tell Heroku-san.
git commit -a -m "Update"
git push heroku master
#### Questions?
That's what the comments section is for, below.
Happy Heroku-ing my new geek friend! :-)
Read more of this story at Slashdot.