From fb2134260a119438ca8f7fb273107cd891a40b67 Mon Sep 17 00:00:00 2001 From: Ivan Habernal Date: Sat, 31 Jul 2021 15:10:07 +0200 Subject: [PATCH] Created Install Tracks 2.5.1 on Ubuntu 20.04 LTS on AWS with SSL support (markdown) --- ...buntu-20.04-LTS-on-AWS-with-SSL-support.md | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 Install-Tracks-2.5.1-on-Ubuntu-20.04-LTS-on-AWS-with-SSL-support.md diff --git a/Install-Tracks-2.5.1-on-Ubuntu-20.04-LTS-on-AWS-with-SSL-support.md b/Install-Tracks-2.5.1-on-Ubuntu-20.04-LTS-on-AWS-with-SSL-support.md new file mode 100644 index 0000000..1348932 --- /dev/null +++ b/Install-Tracks-2.5.1-on-Ubuntu-20.04-LTS-on-AWS-with-SSL-support.md @@ -0,0 +1,108 @@ +Installing Tracks 2.5.1 on a clean server (Ubuntu 20.04 LTS) running on Amazon Web Services with a Let's encrypt SSL certificate for a secure HTTPS access. + +## Install all required dependencies + +```bash +$ sudo apt-get install git nano wget ruby ruby-dev build-essential libsqlite3-dev shared-mime-info -y +``` + +This command has also installed a default `bundler` but we have to replace it with a newer version due to a [bug in the package served with Ubuntu](https://bugs.launchpad.net/ubuntu/+source/ruby-thor/+bug/1885424). + +```bash +$ bundler2.7 --version +Bundler version 2.1.2 +``` + +Install a newer version + +```bash +$ sudo gem install bundler +Fetching bundler-2.2.25.gem +``` + +So now we have a newer version installed + +```bash +$ bundle --version +Bundler version 2.2.25 +``` + +## Download tracks + +```bash +$ wget https://github.com/TracksApp/tracks/archive/v2.5.1.zip +$ unzip v2.5.1.zip +$ cd tracks-2.5.1/ +$ rm Gemfile.lock +``` + +Edit `Gemfile`, I'm using `nano` + +```bash +$ nano Gemfile +``` + +Comment out unused backends + +``` +# gem "mysql2", "~> 0.5.3", group: :mysql +# gem "pg", "~> 1.2.3", group: :postgresql +``` + +```bash +$ cp config/database.yml.tmpl config/database.yml +$ nano config/database.yml +``` + +Change to use `sqlite` backend + +``` +production: +# adapter: mysql2 +# database: tracks + # set this if you are storing utf8 in your mysql database to handle strings + # like "Réné".Not needed for sqlite. For PostgreSQL use encoding: unicode + # encoding: utf8 +# host: localhost +# username: root +# password: + +# The following is an example to configure Tracks to use sqlite + +#production: + adapter: sqlite3 + database: db/tracks-20-blank.sqlite3.db + pool: 5 + timeout: 5000 +``` + +```bash +$ cp config/site.yml.tmpl config/site.yml +$ nano config/site.yml +``` + +Change `change-me` in `secret_token` to some random value. Then compile packages (takes some time). + +## Install using bundler + +We will be installing all Ruby packages into this local folder for not messing up with other possible system-wider libraries + +```bash +$ bundle config set --local path 'vendor/bundle' +$ export RAILS_SERVE_STATIC_FILES=true +$ bundle install +``` + +Compile static assets + +```bash +$ bundle exec rake assets:precompile RAILS_ENV=production +``` + +I have the following script for launching Tracks properly with SSL: + +``` +#!/bin/sh +export RAILS_SERVE_STATIC_FILES=true +bundle exec puma -e production -b 'ssl://0.0.0.0:3000?key=/etc/letsencrypt/live/myserver.com/privkey.pem&cert=/etc/letsencrypt/live/myserver.com/cert.pem' +``` \ No newline at end of file