![](https://reliablevps.net/wp-content/uploads/2024/03/malware-breaking-into-database-screen.jpg)
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.:
- Update Package Index: Before you begin, update your system’s package index with:
sudo apt update
- 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
- 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
- Install Ruby-Build: Install
ruby-build
, which is a plugin forrbenv
to help you compile and install Ruby:git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
- Install Ruby: Use
rbenv
to install the desired version of Ruby.
For example, to install Ruby 3.0.3:rbenv install 3.0.3
- Set Global Ruby Version: Once Ruby is installed, set it as the global version:
rbenv global 3.0.3
- Install Rails: After installing Ruby, you can install Rails using the gem package manager:
gem install rails
- Verify Installation: Verify that Rails has been installed correctly by checking the version:
rails --version
- 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.