Ruby on Rails, or Rails, is a server-side web application framework written in Ruby. It provides default structures for a database, a web service, and web pages. It encourages and facilitates the use of web standards such as JSON or XML for data transfer, and HTML, CSS, and JavaScript for display and user interfacing. "rbenv" is a command-line tool that allows you to install and manage Ruby and Rails.

Install Dependencies

First, we should update “Yum” using the command below:

yum update -y

Next, install the required dependencies for "rbenv" and “Ruby”:

yum install -y git-core zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel git

Once the installation of dependencies finished we can go on and install "rbenv" itself.

Install rbenv

Now, we can install "rbenv" through “Git” with the command below:

git clone git:// .rbenv

You have to add “~/.rbenv/bin” to your executable path, also you can add “~/.rbenv/bin/ rbenv init” to your “~/.bash_profile” so rbenv can start automatically:

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

Source rbenv by typing:

source ~/.bash_profile

You can check if your rbenv is working properly by executing:

type rbenv

Your terminal window should get you the following output:

rbenv is a function
rbenv () 
    local command;
    if [ "$#" -gt 0 ]; then
    case "$command" in 
        rehash | shell)
            eval "$(rbenv "sh-$command" "$@")"
            command rbenv "$command" "$@"

You should install “ruby-build” plugin in order to install various versions of Ruby:

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

Install Ruby

Now, we can install preferred versions of Ruby that we may need, through a simple command.

You can list available version of Ruby with the command below:

rbenv install -l

The output should be a long list of available versions that you can choose to install.

We are going to install the latest stable version of Ruby which is 2.4.1

rbenv install 2.4.1

The installation process may take a few minutes so be patient.

After the installation process is done, we can set the installed version as our default version using the command below:

rbenv global 2.4.1

you can check your Ruby version using the “-v” flag:

ruby -v

The output should be something like below:

ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]

Install Gems

Gems are packages that extend the functionality of Ruby, we would want to install Rails through Gem.

So that the process of installing Rails is less lengthy, we will turn off local documentation for each gem we install. We will also install the bundler gem to manage application dependencies:

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

Install Rails

For installing the latest version of Rails type:

gem install rails

If you want to install a specific version of rails you can get a list of available versions with the command below:

gem search '^rails$' --all

For installing the preferred version type:

gem install rails -v 4.2.7

Check your Rails version using the command below:

rails -v

Updating your rbenv

As we installed rbenv manually using “Git” we can upgrade it to the most recent version at any time:

cd ~/.rbenv
git pull
Bu cevap yeterince yardımcı oldu mu? 0 Bu dökümanı faydalı bulan kullanıcılar: (0 Oy)