Question

How do I deploy a Harp app on DigitalOcean

  • Posted August 9, 2014

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

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

This comment has been deleted

host it with pm2, here is what I do with vagrant. structure like /var/www/hp.com/package.json /var/www/hp.com/node_modules /var/www/hp.com/hpserver.js # the server, which will be hold by pm2 /var/www/hp.com/html # 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- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | 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

  1. Nginx

sudo touch /etc/nginx/sites-available/hp.com sudo nano /etc/nginx/sites-available/hp.com

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;
    server_name localhost;
    #server_name lorem.com www.lorem.com; # the domain
    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_pass         http://127.0.0.1:9000;
    }
}

ref Ghost (a node blogging app) Nginx setting https://www.digitalocean.com/community/tutorials/how-to-host-ghost-with-nginx-on-digitalocean

  1. site content

sudo mkdir -p /var/www/hp.com/html sudo chown -R $USER:$USER /var/www/hp.com/html 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/hp.com/html --boilerplate kennethormandy/hb-remedy site content in /var/www/hp.com/html/public with /var/www/hp.com/html/harp.json (site info)

  1. /var/www/hp.com/hpserver.js

cd /var/www/hp.com 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/hp.com/hpserver.js

Test-to-run: node /var/www/hp.com/hpserver.js 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) ref http://harpjs.com/docs/deployment/azure

  1. pm2

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

then restart vps

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