{"id":29821,"date":"2019-08-13T10:44:35","date_gmt":"2019-08-13T15:44:35","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=29821"},"modified":"2022-06-03T03:33:35","modified_gmt":"2022-06-03T08:33:35","slug":"how-to-install-ruby-on-ubuntu-18-04","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/how-to-install-ruby-on-ubuntu-18-04\/","title":{"rendered":"How to Install Ruby on Ubuntu 18.04"},"content":{"rendered":"
<\/p>\n
In this post, we will show you how to install Ruby on an Ubuntu 18.04 VPS<\/a>.<\/p>\n Ruby is a dynamic, open-source, object-oriented programming language with a focus on simplicity and productivity. It is best known for its use in the Ruby on Rails framework.<\/p>\n Installing Ruby is an easy task and should not take more than 10 minutes. Let’s begin with the installation.<\/p>\n <\/p>\n Before starting, you’ll need to log into your server first. You will need to log in as the root account, or as a user with sudo privileges.<\/p>\n NOTE:\u00a0<\/strong>This method, while not the fastest, will get you the latest version of Ruby (as well as any specific version) installed onto your server. If your application supports a wider range of Ruby versions, then installing using Method 2 (further down in the tutorial) might be the better way, as it is faster.<\/p>\n RVM is a command-line tool that helps you to install, manage and work with multiple Ruby versions.<\/p>\n The following packages are required to install Ruby with RVM and build Ruby gems on your Ubuntu server. Run this command to install them:<\/p>\n Once those packages are installed, install the RVM GPG keys:<\/p>\n The command output will look like this:<\/p>\n Install RVM by running the following command:<\/p>\n Once RVM is installed you will see the following output:<\/p>\n You can now install the latest version of Ruby with the following command:<\/p>\n The command will build Ruby from source and will take some time to complete. The output will look like this:<\/p>\n Verify the ruby version by running the following command:<\/p>\n At the time of writing this article, the latest version of Ruby is 2.6.0.<\/p>\n You can also install Bundler to be able to manage application gem dependencies:<\/p>\n If you want to install a specific Ruby version, use this format to define the version you want to install:<\/p>\n For example, to install Ruby version 2.5.1 on your Ubuntu server, the command would follow this format:<\/p>\n The easiest way to install Ruby is from the Ubuntu APT repository.<\/p>\n Update the Ubuntu package lists to get information on the newest versions of packages and their dependencies, and install Ruby using the following commands:<\/p>\n To check the version of Ruby that was installed, run the following command:<\/p>\n At the time of writing this article, the ruby-full package provides Ruby 2.5.1.<\/p>\n Congratulations, you now have Ruby installed on your Ubuntu 18.04 VPS.<\/p>\n Of course, you don\u2019t have to install Ruby on Ubuntu 18.04 if you use one of our Ruby VPS hosting services<\/a>, in which case you can simply ask our expert Linux admins to install Ruby on Ubuntu 18.04 for you. They are available 24\u00d77 and will take care of your request immediately.<\/p>\n PS.<\/span><\/strong> If you liked this post on how to\u00a0install Ruby on Ubuntu 18.04, please share it with your friends on the social networks using the share shortcuts below, or simply leave a comment down in the comments section. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":" In this post, we will show you how to install Ruby on an Ubuntu 18.04 VPS. Ruby is a dynamic, … <\/p>\nMethod 1: Installing Ruby with RVM<\/h2>\n
sudo apt-get install curl gnupg gnupg2 build-essential libgdbm-dev libncurses5-dev automake libtool bison libffi-dev\r\n<\/pre>\n
sudo gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB<\/pre>\n
gpg: key 105BD0E739499BDB: 5 signatures not checked due to missing keys\r\ngpg: key 105BD0E739499BDB: public key \"Piotr Kuczynski <piotr.kuczynski@gmail.com>\" imported\r\ngpg: key 3804BB82D39DC0E3: 103 signatures not checked due to missing keys\r\ngpg: key 3804BB82D39DC0E3: \"Michal Papis (RVM signing) <mpapis@gmail.com>\" not changed\r\ngpg: no ultimately trusted keys found\r\ngpg: Total number processed: 2\r\ngpg: imported: 1\r\ngpg: unchanged: 1\r\n<\/pre>\n
curl -sSL https:\/\/get.rvm.io | sudo bash -s stable<\/pre>\n
Downloading https:\/\/github.com\/rvm\/rvm\/archive\/1.29.7.tar.gz\r\nDownloading https:\/\/github.com\/rvm\/rvm\/releases\/download\/1.29.7\/1.29.7.tar.gz.asc\r\ngpg: Signature made Thu 03 Jan 2019 04:01:48 PM CST\r\ngpg: using RSA key 7D2BAF1CF37B13E2069D6956105BD0E739499BDB\r\ngpg: Good signature from \"Piotr Kuczynski <piotr.kuczynski@gmail.com>\" [unknown]\r\ngpg: WARNING: This key is not certified with a trusted signature!\r\ngpg: There is no indication that the signature belongs to the owner.\r\nPrimary key fingerprint: 7D2B AF1C F37B 13E2 069D 6956 105B D0E7 3949 9BDB\r\nGPG verified '\/usr\/local\/rvm\/archives\/rvm-1.29.7.tgz'\r\nCreating group 'rvm'\r\nInstalling RVM to \/usr\/local\/rvm\/\r\nInstallation of RVM in \/usr\/local\/rvm\/ is almost complete:\r\n\r\n * First you need to add all users that will be using rvm to 'rvm' group,\r\n and logout - login again, anyone using rvm will be operating with `umask u=rwx,g=rwx,o=rx`.\r\n\r\n * To start using RVM you need to run `source \/etc\/profile.d\/rvm.sh`\r\n in all your open shell windows, in rare cases you need to reopen all shell windows.\r\n * Please do NOT forget to add your users to the rvm group.\r\n The installer no longer auto-adds root or users to the rvm group. Admins must do this.\r\n Also, please note that group memberships are ONLY evaluated at login time.\r\n This means that users must log out then back in before group membership takes effect!<\/pre>\n
To start using RVM you need to run:<\/pre>\n
source \/etc\/profile.d\/rvm.sh<\/pre>\n
rvm install ruby\r\nrvm --default use ruby\r\n<\/pre>\n
ruby-2.6.0 - #extracting ruby-2.6.0 to \/usr\/local\/rvm\/src\/ruby-2.6.0.....\r\nruby-2.6.0 - #configuring......................................................................\r\nruby-2.6.0 - #post-configuration..\r\nruby-2.6.0 - #compiling............. ............................................................................\r\nruby-2.6.0 - #installing...............\r\nruby-2.6.0 - #making binaries executable..\r\nInstalled rubygems 3.0.1 is newer than 2.7.8 provided with installed ruby, skipping installation, use --force to force installation.\r\nruby-2.6.0 - #gemset created \/usr\/local\/rvm\/gems\/ruby-2.6.0@global\r\nruby-2.6.0 - #importing gemset \/usr\/local\/rvm\/gemsets\/global.gems................................................................\r\nruby-2.6.0 - #generating global wrappers.......\r\nruby-2.6.0 - #gemset created \/usr\/local\/rvm\/gems\/ruby-2.6.0\r\nruby-2.6.0 - #importing gemsetfile \/usr\/local\/rvm\/gemsets\/default.gems evaluated to empty gem list\r\nruby-2.6.0 - #generating default wrappers.......\r\nruby-2.6.0 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).\r\nInstall of ruby-2.6.0 - #complete\r\nRuby was built without documentation, to build it run: rvm docs generate-ri\r\n<\/pre>\n
ruby -v\r\n<\/pre>\n
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]\r\n<\/pre>\n
gem install bundler --no-rdoc --no-ri<\/pre>\n
rvm install ruby-X.X.X\r\nrvm --default use ruby-X.X.X\r\n<\/pre>\n
rvm install ruby-2.5.1\r\nrvm --default use ruby-2.5.1\r\n<\/pre>\n
Method 2: Install Ruby with Apt<\/h2>\n
sudo apt-get update\r\nsudo apt-get install ruby-full\r\n<\/pre>\n
ruby -v\r\n<\/pre>\n
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]<\/pre>\n
\n