Installing NodeJS, MongoDB, and Mozilla Popcorn Maker 0.5.2 on Amazon Web Services



Mozilla Popcorn is an open source project being run by Mozilla to “make video work like the web”.  The most important components of the project are the following:

  • Popcorn JS – a JavaScript event framework for HTML5 media.
  • Butter – An SDK for authoring Popcorn projects.
  • Popcorn Maker – An authoring tool that allows you to build and share Popcorn projects without writing any code.

Intended Audience

This post is more technical than others in our Innovation Series.  We think this post will be most helpful to developers who are regularly use JavaScript and who have some very basic experience using Linux.  (Know what SSH is?  Know what the “ls” command does?  Good enough!).

You do NOT need to have any experience working with NodeJS or MongoDB.  We had no prior experience with Node.  We had plenty of experience with both MySQL and MS SQL before diving into this project, but we hadn’t worked with document-oriented databases.  We were pleasantly surprised to have a very easy time making that piece of the puzzle work.

Why Bother?

Why should you bother setting up your own instance of Popcorn Maker when you can play with the live one at  One use case would be if you want to take a stab at extending it with the ability to post your project to WordPress via XML-RPC.  Or maybe you want to save the project JSON to your CMS database.  When you control the codebase, you have all kinds of flexibility!

Step 1: Getting Started with Amazon + Installing Node.js

First, you need to go through the process of signing up for an account, creating your 64 bit Amazon Linux Instance, connecting to it via SSH, and installing Node.js.  We recommend that you follow this tutorial by Kostas Mavropalias while taking the following notes into account:

  • You don’t need to install NPM (node package manager).  It now ships with Node.  This wasn’t the case with older versions.
  • If Node 0.8.5 fails with a “pure virtual function call” error,  try Node 0.8.1 instead.  When we ran our installation, 0.8.2 was the most recent Node.js release and it failed to compile on Amazon Linux due to a known bug.  We worked around it by using Node 0.8.1 instead.  It may not be an issue in Node 0.8.5 but you’ll need to confirm that.
  • Open port 80 (http), 22 (ssh), and 8888 (Popcorn maker’s default port) immediately when setting up your security group.
  • In one step of the tutorial you run the command “sudo su” so that you can edit the ‘sudoers’ file.  After you exit vi, we recommend that you run “sudo su ec2-user” to switch back to the standard user.  Failure to do so may result in issues running upstart scripts later.

Step 2: Installing MongoDB 2.0.6

Popcorn Maker requires MongoDB 2.0.6 or later if you want your instance to allow users to save and load projects.

You’re responsible for deciding an appropriate place to put the Mongo folder and the data folder, but we recommend untarring MongoDB to ~/mongo and then creating  ~/mongo/data to hold the database

  1. Download the .tgz
    [~]$ wget
  2. Untar it
    [~]$ tar -xzf mongodb-linux-x86_64-2.0.6.tgz
  3. Enter the mongo directory
    [~]$ cd mongodb-linux-x86_64-2.0.6.tgz
  4. Create a data directory
    [mongodb-linux-x86_64-2.0.6]$ mkdir /your_chosen_data_dir
  5. Enter the bin directory
    [~]$ cd bin
  6. Run mongoDB and tell it to put the data file in your data directory
    [bin]$ ./mongod –dbpath /your_chosen_data_dir

Step 3: Installing Popcorn Maker 0.5.2

Use Mozilla’s butter readme instructions to install Popcorn Maker.  You’ve already set up Node and MongoDB, but be sure to look at the following sections:

  • “Environment Setup”.
  • “Running Butter (with cornfield)”
  • The “node make storycamp” part is important.  If  you don’t do it, the main GUI will work but you won’t be able to use all of the handy templates that ship with PopcornMaker 0.5.2

Note that these steps were tested with the files for 0.5.2.   You may hit a snag or two if they made big changes to Popcorn Maker, so feel free to ask us questions in the comments and we’ll do our best to help!

At this point you should be able to browse to your installation at port 8888.

Optional Step 4: Map port 8888 to Port 80

By default, the Popcorn Maker app runs on port 8888.  In Linux, users other than ‘root’ may not be able to bind processes to port 80, so a workaround is to run Popcorn Maker on :8888 and redirect traffic to port 80 using iptables.

Our use of iptables consisted of 3 steps:

  1. Add a rule to the prerouting table to route port 8888 to port 80
  2. Save this rule to a file using iptables-save
  3. Load this rule on startup using an upstart script (see optional step 5)

We recommend this resource on the iptables command:

Our file wound up looking like this.

# Generated by iptables-save v1.4.12 on Wed Jun 27 20:52:08 2012
-A PREROUTING -i eth0 -p tcp -m tcp –dport 80 -j REDIRECT –to-ports 8888
# Completed on Wed Jun 27 20:52:08 2012

Optional Step 5: Running Node and Mongo as Services using Upstart

Upstart allows you to run shell scripts whenever you boot a Linux Instance by placing scripts with a .conf ending in the /etc/init directory.  We configured our server to run 3 critical steps on startup:

  • Map port 8888 to port 80 (see optional step 4)
  • Start MongoDB
  • Start NodeJS app

We recommend that you create the  following script using these commands:

cd /etc/init
sudo vi popjs.conf

Enter the following content into popjs.conf:

description “Run MongoDB and Node.js as services”
author      ”Joe Flowers, based on original script by Jon Buckley”

env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

start on runlevel [23]


#emove the following line if you don’t use iptables to route port 8888 to port 80
iptables-restore < /home/ec2-user/nodeapps/butter/iptabledata

/home/ec2-user/mongo/bin/mongod –dbpath /home/ec2-user/mongo/data &
export NODE_ENV=production
cd /home/ec2-user/nodeapps/butter/cornfield
exec node app.js
end script

Any Questions?

If you run into any issues with our instructions, please leave us a note in the comments and we’ll see if we can help!

- – – – -

(Thank you to Adam Martin and Joe Flowers for their contributions to this post.)

(The foregoing commentary does not constitute endorsement by the US Government, the Broadcasting Board of Governors, VOA, MBN, OCB, RFA, or RFE/RL of the information products or services discussed.)

The following two tabs change content below.
Joe Flowers

Joe Flowers

Joe Flowers is a former Consultant for the Office of Digital & Design Innovation. Follow him on Twitter: @jflowers45.

Leave a Reply

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

* Copy This Password *

* Type Or Paste Password Here *