Setup Ruby On Rails Development Environment On Ubuntu/Debian

Exported on 28-Aug-2021 16:44:16

Installs Ruby on Rails Development Environment

Parameters

Name Type Script Reference Default Value Comment
s1 Linux / Unix Server s1
s1c Linux OS Credential s1c

1 - Install ROR Dependencies

Installs prerequisites for the Ruby on Rails environment

The connection details have changed from the last step.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Install curl
sudo apt-get install curl

# Install NodeJS
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -

# Configure source list
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

# Install dependencies
sudo apt-get -y update
sudo apt-get -y install git-core zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs yarn

2 - Install rbenv

Install rbenv and ruby version 3.0.1

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Configure git
git clone https://github.com/rbenv/rbenv.git ~/.rbenv

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

# Install rbenv and set global version
~/.rbenv/bin/rbenv install 3.0.1
~/.rbenv/bin/rbenv global 3.0.1

#Create symlinks
sudo ln -s ~/.rbenv/versions/3.0.1/bin/* /usr/bin/

ruby -v

3 - Install Rails

Installs rails and bundler

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Install bundler
gem install bundler

# Install rails
gem install rails -v 6.1.3.2

# Link rails
sudo ln -s ~/.rbenv/versions/3.0.1/bin/rails /usr/bin/rails

# Rehash and check version
~/.rbenv/bin/rbenv rehash
rails -v

4 - Install PostgreSQL

Installs PostgreSQL database and PSQL development libraries

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Installs and configures postgreSQL
sudo apt -y install postgresql libpq-dev

5 - Setup Rails Application

Creates new rails project, sets up a new postgres role and executes the migration for the ROR app.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
#Create ror project
rails new myapp -d postgresql
cd myapp

# Create postgres user/role
sudo -u postgres createuser --superuser $(whoami)

# Run migration
rake db:create

6 - Start Rails Development Server

Starts the rails development server, accessible at https://YOUR_IP:3000/

You can access the server process by using the command: screen -x

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
cd myapp

# Install screen 
sudo apt -y install screen
sudo echo "zombie xy" >> ~/.screenrc

# Start the development 
screen -d -m rails server -b 0.0.0.0