node.js on ubuntu (on linode)

I got my simple movies node.js app running through Apache using mod_proxy

$ a2enmod proxy_http
$ a2enmod proxy

Configured under sites-available like so:

$ cat /etc/apache2/sites-available/movies 
<VirtualHost *:80>
    ServerName actualfqdnofhost.bluebones.net
    ServerAlias movies.bluebones.net
    ProxyPass / http://127.0.0.1:3000/
    <Proxy *>
	Allow from all
    </Proxy>
</VirtualHost>

(This assumes that your app listens on port 3000 when running.)

Then to ensure it gets restarted when the machine does I created the following file as /etc/init/movies.conf

$ cat /etc/init/movies.conf 
description "movies.bluebones.net on node.js"
author "bakert"

start on startup
stop on shutdown

script
  export MOVIES_ROOT=/srv/movies
  export EXPRESS_ROOT=$MOVIES_ROOT/src/express
  cd $EXPRESS_ROOT && exec sudo -u www-data NODE_PATH=$NODE_PATH:/opt/local/node/lib/node_modules/ EXPRESS_ENV=production /opt/local/node/bin/node $EXPRESS_ROOT/app.js 2>&1 >>$MOVIES_ROOT/logs/node.log
end script

Which also lets me stop and start my app with:

$ start movies
$ stop movies

One Reply to “node.js on ubuntu (on linode)”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.