Rolling your own VPS with multiple meteor/nodejs apps

Below is my process for setting up a new VPS to serve one or more bundled meteor apps (could be read as nodejs apps). Once the droplet is created, I normally add a swap file to help with memory management during deploys.

Updated for Meteor 1.4.2

Whenever you see [[some-text]] it is meant as a placeholder and you should replace it with the value specific to your case.

Partly based on this link

Install build tools and git

Install nvm

Ensure nvm is on the path with

Install node for meteor

Copy the installed version of node to the /usr/local (where user installed global files should live on a linux VPS) and setting the permissions so that all users can access them.

Install forever

Install meteor

OPTIONAL: Install dependencies for your build tasks (e.g. coffee-script)

Setup git deploy hook to deploy files, see link.

If these don’t exist yet

Export some vars to reuse in the terminal

Prepare for the git hook

Add the following to the post-receive file

Set permissions on post-receive

Create a shell script in /var/node/[[app-name]]/

And add the following while replacing the variables as needed:

Ensure the app is started after reboot by adding a cronjob:

Note: Ensure your domain is pointed to your VPS IP.

From local machine

Back on the server, setup the reverse proxy with nginx

Add the following to the /etc/nginx/sites-available/[[]].conf file

Add a symlink from sites-enabled

Reload nginx configurations

To start your app:

Tagged with: , , , , , , ,
Posted in Blog, Develop