8

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

 3 years ago
source link: https://dev.to/leewynne/how-to-build-a-ruby-on-rails-app-on-aws-for-beginners-part-1-p5n
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

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
Enter fullscreen modeExit 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 modeExit 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 modeExit fullscreen mode

Now all we need to do is install bundler

gem install bundler

Enter fullscreen modeExit fullscreen mode

Next up, installing Rails

gem install rails -v 6.1.3.2
Enter fullscreen modeExit fullscreen mode

To make the Rails executable available:

rbenv rehash
Enter fullscreen modeExit fullscreen mode

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

rails -v
Enter fullscreen modeExit fullscreen mode

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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK