Deploying a private Standard File server with Amazon EC2 and Nginx

Mo Bitar edited this page Jun 13, 2018 · 16 revisions

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 1GB 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.

Note: you can skip most of these steps by using our public AMI. See this guide for more details: Deploying a Standard File server on AWS with a pre configured image

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-devel

    sudo yum install mysql-devel
  9. 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 chkconfig mysqld on

    Create a database:

    mysql -u root -p
    > create database standard_file;
    > quit;
  10. Install Passenger:

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

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

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

    sudo yum install git
  14. 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/

  15. 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/ruby-server/public;
  16. Make sure you are in your home directory and clone the Standard File ruby-server project:

    cd ~
    git clone
    cd ruby-server
  17. Setup project:

    bundle install
    bower install
    rails assets:precompile
  18. 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"
  19. Setup database:

    rails db:migrate
  20. 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
  21. 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, enter the address of your new server and press Change Server:


Then, register for a new account, and begin using your private new secure Standard File server!

Note: if you want to access the Rails console using bundle exec rails c production, you might need to install NodeJS:

sudo yum install nodejs npm --enablerepo=epel

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.