How to install Ruby on Rails with rbenv on ubuntu 22.04?

How to install Ruby on Rails with rbenv on ubuntu 22.04?

You should follow those steps to deploy Ruby on Rails with rbenv on Ubuntu 22.04.:

  1. Update Package Index: Before you begin, update your system’s package index with:
    sudo apt update
  2. Install Dependencies: Install the necessary dependencies for Ruby:
    sudo apt install -y git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev
  3. Install rbenv: Clone rbenv repository from GitHub:
    git clone https://github.com/rbenv/rbenv.git ~/.rbenv

    Then, add rbenv to your PATH:

    echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
    echo 'eval "$(rbenv init -)"' >> ~/.bashrc
    source ~/.bashrc
  4. Install Ruby-Build: Install ruby-build, which is a plugin for rbenv to help you compile and install Ruby:
    git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
  5. Install Ruby: Use rbenv to install the desired version of Ruby.
    For example, to install Ruby 3.0.3:

    rbenv install 3.0.3
  6. Set Global Ruby Version: Once Ruby is installed, set it as the global version:
    rbenv global 3.0.3
  7. Install Rails: After installing Ruby, you can install Rails using the gem package manager:
    gem install rails
  8. Verify Installation: Verify that Rails has been installed correctly by checking the version:
    rails --version
  9. Initialize Rails App (Optional): If you want to create a new Rails application, you can do so using the following command:
    rails new myapp

Replace “myapp” with the name you want for your Rails application.

And that’s it! On Ubuntu 22.04, you have successfully installed Ruby on Rails using rbenv.

Post Your Comment

Free Migration Assistance

If you need assistance with migrating your current data from another provider, we would be more than happy to assist.