Skip to content

Latest commit

 

History

History
197 lines (155 loc) · 5.74 KB

installing.adoc

File metadata and controls

197 lines (155 loc) · 5.74 KB

Ruby on Rails Install How-to

Development System

This chapter’s installation methods described are intended for development systems.

Ruby on Rails 5.2 on Debian 9.3 (Stretch)

There are two main reasons for installing a Ruby on Rails system with RVM (Ruby Version Manager):

  • You simply do not have any root rights on the system. In that case, you have no other option.

  • You want to run several Rails systems that are separated cleanly, and perhaps also separate Ruby versions. Maybe not today but for a future system upgrade. This can be easily done with RVM.

Note
Detailed information on RVM can be found on the RVM homepage at https://rvm.io

This description assumes that you have a freshly installed Debian GNU/Linux 9.3 ("Stretch"). You will find an ISO image for the installation at http://www.debian.org. I recommend the approximately 250 MB net installation CD image. For instructions on how to install Debian-GNU/Linux, please go to http://www.debian.org/distrib/netinst.

Preparations

If you have root rights on the target system, you can use the following commands to ensure that all required programs for a successful installation of RVM are available. If you do not have root rights, you have to either hope that your admin has already installed everything you need, or send them a quick e-mail with the corresponding lines.

Login as root, update the package lists and upgrade the system:

root@debian:~# apt-get update
[..]
root@debian:~# apt-get upgrade

Installation of the packages required for the RVM installation:

root@debian:~# apt-get -y install curl gawk g++ \
make libreadline6-dev zlib1g-dev libssl-dev \
libyaml-dev libsqlite3-dev sqlite3 autoconf \
libgdbm-dev libncurses5-dev libtool bison nodejs \
pkg-config libffi-dev libgmp-dev libgmp-dev git \
dirmngr

Now is a good time to log out as root:

root@debian:~# exit
logout
xyz@debian:~$

Installing Ruby 2.5 and Ruby on Rails 5.2 with RVM

Log in with your normal user account (in our case, it’s the user xyz).

RVM, Ruby, and Ruby on Rails can be installed in various ways. I recommend using the following commands and get at least one cup of tea/coffee/favorite drink:

xyz@debian:~$ gpg --keyserver hkp://keys.gnupg.net --recv-keys \
409B6B1796C275462A1703113804BB82D39DC0E3 \
7D2BAF1CF37B13E2069D6956105BD0E739499BDB
[...]
xyz@debian:~$ curl -sSL https://get.rvm.io | bash
[...]

To be able to use RVM you need to run a script first. rvm will tell you which script (it’s path depends on the user name):

xyz@debian:~$ source /home/xyz/.rvm/scripts/rvm

Now you can use RVM to install Ruby 2.5 and after that the current Rails version with 'gem':

xyz@debian:~$ rvm install 2.5
[...]
xyz@debian:~$ gem install rails
[...]
xyz@debian:~$
Tip
gem install rails installs the current stable Rails version. You can use the format gem install rails -v 5.2.0 to install a specific version and gem install rails --pre to install a current beta version.

RVM, Ruby 2.6 and Rails 5.2 are now installed. You can check it with the following commands.

xyz@debian:~$ ruby -v
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux]
xyz@debian:~$ rails -v
Rails 5.2.0
xyz@debian:~$

Ruby on Rails 5.2 on macOS 10.13 (High Sierra)

macOS 10.13 includes Ruby by default. Not interesting for our purposes. We want Ruby 2.5 and Rails 5.2. To avoid interfering with the existing Ruby and Rails installation and therefore the packet management of Mac OS X, we install Ruby 2.5 and Rails 5.2 with RVM (Ruby Version Manager).

With RVM, you can install and run any number of Ruby and Rails versions as normal user (without root rights and in your home directory).

Note
Detailed information on RVM can be found at the RVM homepage at https://rvm.io/

Xcode Installation or Upgrade

Before you start installing Ruby on Rails, you must install the latest Apple Xcode tools on your system. The easiest way is via the Mac App Store (search for "xcode") or via the website https://developer.apple.com/xcode/

Important
Please take care to install all the command line tools!

Installing Ruby 2.5 and Ruby on Rails 5.2 with RVM

RVM can be installed in various ways. I recommend using the following monster command (please copy it exactly) that installs the latest RVM, Ruby and Ruby on Rails in your home directory:

$ gpg --keyserver hkp://keys.gnupg.net --recv-keys \
409B6B1796C275462A1703113804BB82D39DC0E3 \
7D2BAF1CF37B13E2069D6956105BD0E739499BDB
[...]
$ curl -sSL https://get.rvm.io | bash
[...]

rvm will tell you a source command which you can run to setup rvm for your current shell/terminal. Most times it is just easier to close the current shell and open a new terminal window. Than everything in the new terminal is setup properly.

$ rvm install 2.5
[...]
$ gem install rails
[...]
$
Tip
gem install rails installs the current stable Rails version. You can use the format gem install rails -v 5.2.0 to install a specific version and gem install rails --pre to install a current beta version.

RVM, Ruby 2.5 and Rails 5.2 are now fully installed. You can check it with the following commands.

$ ruby -v
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]
$ rails -v
Rails 5.2.0