Skip to content
Nulifier edited this page Sep 30, 2015 · 12 revisions

How to deploy this app to a DigitalOcean Server

Server Setup

Most of this can be done by just using a pre-made snapshot.

Setup User

  • Setup a user to run the node server under sudo adduser --disabled-password --system --group --home /var/node --shell /bin/bash node

Setup Database

  • Run the command sudo apt-get install mysql-server to install the MySQL server. Enter a strong password for the root user.
  • After the installation is complete, run the command mysql_secure_installation. It will ask for the current root password and ask you to change it. It isn't required as you have already set it. After that it will ask a series of questions. You can safely answer yes to all of these.
  • You can login to the MySQL command line with mysql -u root -p and entering your MySQL root password at the prompt.
  • Once logged on to MySQL you can create a user by running CREATE USER 'myusername'@'localhost' IDENTIFIED BY 'mypassword';
  • Create a database for the site to use by CREATE DATABASE mydatabase CHARACTER SET utf8 COLLATE utf8_general_ci;
  • Grant permission for the site user on that database with GRANT ALL ON mydatabase.* TO 'myusername'@'localhost';

Setup Node.js

  • Setup Node for Production (Use a PPA to avoid having to update manually)
  • Login to the seperate user for running node applications with sudo su node
  • Run the command pm2 startup ubuntu to get a command that should be run as root to start the application
  • Once that command is run, you may need to edit the home folder in /etc/init.d/pm2-init.sh to point to /var/node
  • All pm2 commands should be run as this user.

Setup Nginx

To Do

Deployment

To Do

Considerations for Larger Deployment

  • VPN between servers
  • PM2