Self-Hosting with EC2 and Nginx

These instructions make the following assumptions:

  • You've just finished using the AWS web console to launch an EC2 server with a 64 bit version of Amazon Linux AMI with at least 1 GB of memory.

  • You've configured your security groups to allow for incoming SSH connections from your local IP.

  • You've configured a domain name (or subdomain) to point to your server's IP address.

Getting started

  1. SSH into your new server with the keys you should have received after launching an instance:

    ssh -i /path/to/key.pem
  2. Update your system:

    sudo yum update
  3. Install RVM (Ruby Version Manager):

    gpg --keyserver hkp:// --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
    \curl -sSL | bash -s stable
  4. Begin using RVM in current session:

    source /home/ec2-user/.rvm/scripts/rvm
  5. Install Ruby

    rvm install ruby

    This should install the latest version of ruby (2.3 at the time of this writing.)

    Note that at least Ruby 2.2.2 is required for Rails 5.

  6. Use Ruby

    rvm use ruby
  7. Install Bundler:

    gem install bundler --no-ri --no-rdoc
  8. Install MySQL (optional; you can also use a hosted db through Amazon RDS, which is recommended):

    sudo yum install mysql56-server
    sudo service mysqld start
    sudo mysql_secure_installation
    sudo yum install mysql-devel
    sudo chkconfig mysqld on

    Create a database:

    mysql -u root -p
    > create database standard_notes;
    > quit;
  9. Install Passenger:

    sudo yum install rubygems
    gem install rubygems-update --no-rdoc --no-ri
    gem install passenger --no-rdoc --no-ri
  10. Remove system Nginx installation if installed (you'll use Passenger's instead):

    sudo yum remove nginx
    sudo rm -rf /etc/nginx
  11. Configure Passenger:

    sudo chmod o+x "/home/ec2-user"
    sudo yum install libcurl-devel
    rvmsudo passenger-install-nginx-module
    rvmsudo passenger-config validate-install
  12. Install Git:

    sudo yum install git
  13. Set up HTTPS/SSL for your server (free using LetsEncrypt) (required if using the secure client on

    sudo chown ec2-user /opt
    cd /opt
    git clone
    cd letsencrypt

    Run the setup wizard:

    ./letsencrypt-auto certonly --standalone --debug

    Note the location of the certificates, typically /etc/letsencrypt/live/

  14. Configure Nginx:

    sudo vim /opt/nginx/conf/nginx.conf

    Add this to the bottom of the file, inside the last curly brace:

    server {
    listen 443 ssl default_server;
    ssl_certificate /etc/letsencrypt/live/;
    ssl_certificate_key /etc/letsencrypt/live/;
    passenger_enabled on;
    passenger_app_env production;
    root /home/ec2-user/syncing-server/public;
  15. Make sure you are in your home directory and clone the Standard Notes syncing-server project:

    cd ~
    git clone --single-branch --branch master
    cd syncing-server

Note: The master branch has the latest, stable code. Use this branch in production environments.

  1. Setup project:

    bundle install
    bower install
    rails assets:precompile
  2. Create a .env file for your environment variables. The Rails app will automatically load these when it starts.

    vim .env


    SECRET_KEY_BASE=use "bundle exec rake secret"
  3. Setup database:

rails db:migrate
  1. Start Nginx:

    sudo /opt/nginx/sbin/nginx

    Tip: you will need to restart Nginx whenever you make changes to your environment variables or the Nginx configuration:

    sudo /opt/nginx/sbin/nginx -s reload
  2. You're done!

Using your new server

You can immediately start using your new server by using the Standard Notes app at

In the account menu, choose Advanced Options and enter the address of your new server in Sync Server Domain.

Then, register for a new account or log into an existing account and begin using your private new secure Standard Notes server!

Last updated on