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:
Then select your plan (I chose the $10 for now)
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.
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
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
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
Now all we need to do is install bundler
gem install bundler
Next up, installing Rails
gem install rails -v 6.1.3.2
To make the Rails executable available:
rbenv rehash
Check you have everything installed (this should return the installed version):
rails -v
Job done next up this series is installing PostgreSQL for the DB.
Top comments (0)