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

Exported on 28-Aug-2021 16:32:37

Quickly install and setup a ruby on rails development environment on Debian based systems.

Parameters

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

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 NodeJS

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