Big Bang Technology

Sun 07 Mar
2010

Installation, Configuration, Deployment: node.js Applications on Media Temple

Posted at 11:08 AM by Cameron Westland in Tutorials

I'm very excited about node.js. I'm sure if you're a javascript fan that you've heard about it too. I'll leave determining the usefulness of node to you. This article serves as a guide to installing, configuring, and deploying node.js on a media temple dedicated virtual server. Even without a Media Temple (dv) you should be able follow along on your own server.

Prerequisites

Install application

I'm not going to list every step in detail here. This article assumes basic knowledge of FTP or git. I checkout my application to /var/www/vhosts/:virtual_host/application.

We're going to set up supervisor to pipe stdout and stderr to seperate log files. We need to make sure we've created the appropriate log directories before we do that though. Replace :virtual_host with the host you've created.

We also need a startup script so that supervisor can start up our application.

Now we're ready to configure our node server and make sure that it's reliably running.

Install node.js

  1. SSH into machine with root access.
  2. Create a source folder, download, install, and compile node.

Testing the application

At this point, you should be able to run the node binary and test your application.

Deployment Configuration

I use supervisor for managing the node process. The easiest way to install it is by using the pythong setup tools package.

Install setup tools

Now that setup tools is installed, supervisor is very easy to setup.

Configure supervisor

The manual for supervisor is very straightforward. We create a configuration file. Specifiy our application in the configuration. And set supervisord to start automaticaly.

Test out supervisor by launching supervisord. You can check the status of your application by launching supervisorctl. See the manual for more options. We can now manually start up supervisor so it launches (with our application) on startup. This is useful in the event that your server gets rebooted. To do this, we create an init script:

Now supervisor will start when the server boots up.

Apache Configuration

The last step is to configure Apache to route non-static requests over to node:

Restart the apache process by typing /etc/init.d/http restart and test your server! Viola!

If you have problems with any of these steps or any questsions feel free to @camwest on twitter.