Setup Ruby On Rails Development Environment – CentOS/Fedora/Red Hat

Exported on 07-Oct-2021 22:34:29

Install Ruby On Rails Development Environment On RHEL Based Servers With AttuneOps

This Blueprint Installs Ruby On Rails Development Server On RHEL Based Servers

Ruby on Rails is a server-side web application framework under the MIT License written in Ruby. Rails is a model–view–controller framework, providing web services, web pages, and default structures for a database,.

Ruby ranks amongst the top ten programming languages predominantly because of the voguishness of Rails. While it's clear that Ruby is a more difficult programming language to master, in many ways, it is a more robust language that is better suited for creating business applications.

Pre-Blueprint Attune setup
  1. On the Inputs tab, create a Linux node for the host you wish to install the stack on.
  2. On the Inputs tab, create Linux credentials to connect to the host you wish to install the stack on.
Steps Involved
  • Update yum repositories.
  • Install prerequisites.
  • Install Node, rbenv and postgres Database.
  • Create ROR project.
  • Launch ROR development server.
Supported Operating Systems
  • CentOS
  • Fedora
  • Red Hat

Parameters

Name Type Script Reference Default Value Comment
Linux Node Linux / Unix Server linuxNode
Linux User Linux OS Credential linuxUser

1 - Update yum repositories

Update yum repositories.

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
sudo yum -y update

2 - Install Basic Dependencies

Installs prerequisites for the ROR development environment.

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
sudo  yum install -y git-core zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel git screen
sudo echo "zombie xy" >> ~/.screenrc

3 - Install node and npm

Installs NodeJS and npm, required to install frontend dependencies.

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
# Download setup script
sudo curl -fsSL https://rpm.nodesource.com/setup_16.x -o nodesource.sh

# Configure install script
sudo bash nodesource.sh

# Start installation 
sudo yum install -y nodejs

4 - Install rbenv

Installs rbenv package and configures path of the system to include rbevn executable.

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
git clone git://github.com/sstephenson/rbenv.git .rbenv

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

source ~/.bash_profile

5 - Install Ruby and Rails

Installs ruby v3.0.1, bundle and rails.

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
# Clone repo
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

rbenv install 3.0.1
rbenv global 3.0.1

ruby -v

echo "gem: --no-document" > ~/.gemrc
gem install bundler
gem install rails -v 6.1.3.2
rails -v

6 - Setup 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
# Download psql-devel, psql-server and psql-libs
curl -o psql-pgdg.rpm https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/postgresql96-9.6.22-1PGDG.rhel7.x86_64.rpm
curl -o psql-server.rpm https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/postgresql96-server-9.6.22-1PGDG.rhel7.x86_64.rpm
curl -o psql-libs.rpm https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/postgresql96-libs-9.6.22-1PGDG.rhel7.x86_64.rpm

# Install downloaded rpms
sudo yum -y install psql-libs.rpm
sudo yum -y install psql-pgdg.rpm
sudo yum -y install psql-server.rpm

# Start postgres server
sudo /usr/pgsql-9.6/bin/postgresql96-setup initdb
sudo systemctl start postgresql-9.6

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

7 - Setup ROR project

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 project
rails new myapp -d postgresql
cd myapp

# Migrate DB
rake db:create

# Install bundles and deps
sudo yum -y install postgresql-devel
gem install compass
bundle install
sudo npm install -g yarn
rails webpacker:install

8 - Start ROR Dev 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
sudo yum -y install screen
screen -d -m rails server -b 0.0.0.0