DEV Community

Cover image for How to build a Ruby on Rails app on AWS for beginners - Part 1.
Lee Wynne
Lee Wynne

Posted on • Edited on • Originally published at theelastic.guru

How to build a Ruby on Rails app on AWS for beginners - Part 1.

This is part one of a series of posts, this post covers the initial provisioning of a Ruby on Rails app on AWS using LightSail which is the simplest way of getting started with compute and databases on AWS.

Let's get started by creating an AWS account and building a Linux host to run our Ruby on Rails app with AWS LightSail.

Provisioning a Linux instance to run a Ruby on Rails app on AWS LightSail.

This post will guide you through getting started with your first AWS LightSail compute instance. Before you follow the article though, you need to remember to choose Ubuntu as the OS as per below:

aws Ruby on Rails host

Then select your plan (I chose the $10 for now)

aws Ruby on Rails host ec2 or lightsail

Okay, once that's done, click on the little command line icon next to you instance and you should get a new console tab, all logged in and ready to go.

Screenshot 2021-02-17 at 12.33.07

Installing Node and Yarn to support Webpacker in Ruby on Rails.

sudo apt install curl
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - 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
Enter fullscreen mode Exit fullscreen mode
sudo apt-get update
sudo apt-get 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
Enter fullscreen mode Exit fullscreen mode

Installing rbenv and then Ruby

Great, let's install a Ruby. We are going to install it using rbenv which allows you to run multiple versions of Ruby side by side if needed.

cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

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

rbenv install 3.0.0
rbenv global 3.0.0
ruby -v
Enter fullscreen mode Exit fullscreen mode

Now all we need to do is install bundler

gem install bundler

Enter fullscreen mode Exit fullscreen mode

Next up, installing Rails

gem install rails -v 6.1.3.2
Enter fullscreen mode Exit fullscreen mode

To make the Rails executable available:

rbenv rehash
Enter fullscreen mode Exit fullscreen mode

Check you have everything installed (this should return the installed version):

rails -v
Enter fullscreen mode Exit fullscreen mode

Job done next up this series is installing PostgreSQL for the DB.

Top comments (0)