How To Install Ruby on Rails 6 with Jemalloc on Linux Ubuntu 19.04

Here is the steps to install Ruby on Rails 6 with Jemalloc on Linux Ubuntu 19.04

First we need to update & upgrade ubuntu packages :

sudo apt update && sudo apt upgrade

Then install its dependencies :

sudo apt install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev libjemalloc-dev git -y

Next, clone rbenv repository from github :

git clone ~/.rbenv
git clone ~/.rbenv/plugins/ruby-build

And then add rbenvĀ  path to bashrc :

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

Make rbenv to be available on the current terminal environment :
source ~/.bashrc

Now install ruby :

RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 2.6.4

Make the installed ruby version as global :

rbenv global 2.6.4

Verify if ruby was properly installed with :

ruby -v

Next verify if jemalloc was also properly installed :

ruby -r rbconfig -e "puts RbConfig::CONFIG['LIBS']"

-lpthread -ljemalloc -lgmp -ldl -lcrypt -lm # -ljemalloc should appear on the output

Install NodeJS :

sudo apt-get install curl
curl -sL | sudo -E bash -
sudo apt-get install nodejs

Install Yarn :

curl -sL | sudo apt-key add -
echo "deb stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn

Configure gem default install without rdoc :

echo "gem: --no-document" > ~/.gemrc

Install bundler gem :

gem install bundler

Install rails gem :

gem install rails

Rehash rbenv shims :

rbenv rehash

Finally let’s generate new rails app :

rails new myapp

Scroll to Top
%d bloggers like this: