How do I deploy a Harp app on DigitalOcean

Posted August 9, 2014 3.7k views

I created a website with Harp.js (, but I have no clue how to deploy it on my DigitalOcean server. Can someone please help?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
3 answers

See How To Use PM2 to Setup a Node.js Production Environment On An Ubuntu VPS. You can use the user you created while following Initial Server Setup with Ubuntu 14.04 as the “safeuser”.

by Jim Cassidy
Use these instructions to setup an Ubuntu server to run Node.js applications, including apps based on Express, Geddy, or Sails. This will help you avoid some security mistakes and will provide some surprising benefits.

host it with pm2, here is what I do with vagrant. structure like
/var/www/ # the server, which will be hold by pm2
/var/www/ # site content, so here are the harp-content like html/harp.json , html/public/articles , html/public/index.jade

  1. node -v
    I use nvm to install node, which you can use some alternative way. The point is node version.

    curl -o- | bash
    nvm install 4.4.3 ( dont run nvm install stable because it will install v6.0.0 which is not robust yet )
    nvm alias default 4.4.3
    nvm use default

  2. Nginx

    sudo touch /etc/nginx/sites-available/
    sudo nano /etc/nginx/sites-available/

    server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;
    server_name localhost;
    #server_name; # the domain
    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_set_header X-NginX-Proxy true;

    ref Ghost (a node blogging app) Nginx setting

  3. site content

    sudo mkdir -p /var/www/
    sudo chown -R $USER:$USER /var/www/
    sudo chmod -R 755 /var/www
    npm install -g harp ( will install 0.20.3 and it is ok for harp cmd , but not for the server )
    harp init /var/www/ –boilerplate kennethormandy/hb-remedy
    site content in /var/www/ with /var/www/ (site info)

  4. /var/www/

    cd /var/www/
    touch package.json
    echo “{}” >> package.json
    npm install harp@0.19.0 –save
    echo “require(‘harp’).server(__dirname+’/html’, { port: process.env.PORT || 9000 })” >> /var/www/

    Test-to-run: node /var/www/ and should have no error. If you don’t specify harp@0.19.0 then there might be errors ( like asking to do npm rebuild node-sass or the libsass binding was not found ) in harp@0.20.3 (the latest version which would do default install)

  5. pm2

    npm install -g pm2
    pm2 startup ubuntu # then do as prompt cmd

    then restart vps

    pm2 start /var/www/
    pm2 dump && pm2 kill && pm2 resurrect
    Now as the vps starts, pm2 will trigger hpserver.js and serving every changes to /var/www/
    For back up, just save the whold dir ( hpserver.js + package.json + node_modules dir + html dir )

by Alex LaFroscia
This is our tutorial on hosting Ghost with Nginx on DigitalOcean.