This tutorial is out of date and no longer maintained.
This article covers a version of Ubuntu that is no longer supported. If you are currently operate a server running Ubuntu 12.04, we highly recommend upgrading or migrating to a supported version of Ubuntu:
Reason: Ubuntu 12.04 reached end of life (EOL) on April 28, 2017 and no longer receives security patches or updates. This guide is no longer maintained.
See Instead:
This guide might still be useful as a reference, but may not work on other Ubuntu releases. If available, we strongly recommend using a guide written for the version of Ubuntu you are using. You can use the search functionality at the top of the page to find a more recent version.
Ruby on Rails is an application stack that provides developers with a framework to quickly create a variety of web applications. Ruby on Rails does take a little while to install on a virtual server, but luckily there are a lot of helpful tools to make this process as easy as possible. You can run this tutorial on your droplet as a user with sudo privileges. You can check out how to set that up here: Ubuntu Server Setup
Before we do anything else, we should run a quick update to make sure that all of the packages we download to our VPS are up to date:
sudo apt-get update
Once that's done, we can start installing RVM, Ruby Version Manager. This is a great program that lets you use several versions of Ruby on one server; however, in this case, we will just use it to install the latest version of Ruby on the droplet.
If you do not have curl on your system, you can start by installing it:
sudo apt-get install curl
To install RVM, open terminal and type in this command:
\curl -L https://get.rvm.io | bash -s stable
After it is done installing, load RVM. You may first need to exit out of your shell session and start up a new one.
source ~/.rvm/scripts/rvm
In order to work, RVM has some of its own dependancies that need to be installed. To automatically install them:
rvm requirements
You may need to enter your root password to allow the installation of these dependencies.
On occasion the zlib package may be reported as missing. The RVM page describes the issue and the solution in greater detail here.
Once you are using RVM, installing Ruby is easy.
rvm install ruby
The latest ruby is now installed. However, since we accessed it through a program that has a variety of Ruby versions, we need to tell the system to use the version we just installed by default.
rvm use ruby --default
The next step makes sure that we have all the required components of Ruby on Rails. We can continue to use RVM to install gems; type this line into terminal.
rvm rubygems current
Once everything is set up, it is time to install Rails. To start, open terminal and type in:
gem install rails
This process may take a while, be patient with it. Once it finishes you will have Ruby on Rails installed on your droplet.
Once you have installed Ruby on Rails on your server, you can proceed to Create a SSL Certificate for your site or Install an FTP server
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
you might want to sudo apt-get curl before you try to run the curl command to fetch the rvm installer. It’s in the rvm dependencies, but that’s too late.
Thanks for the feedback, most of the virtual server images we deploy on DigitalOcean have curl pre-installed but we’ll update the documentation because that’s a great point.
The only problem I had was even though I install all the dependencies I am still missing a libz package so before I do “rvm install 1.9.3” I needed to write “$rvm pkg install zlib” … because I got this error “ERROR: Loading command: install (LoadError) cannot load such file – zlib ERROR: While executing gem … (NameError) uninitialized constant Gem::Commands::InstallCommand” … I had to rvm remove default and install it again and then I was good :) Thanks for the help!
We’ll add the libz into the requirements, our base OS was most likely a bit different from the get go but its a good thing to watch out for.
Thanks.
Thank you for catching the issue with zlib. It seems that missing the zlib package is a common problem—it is described in greater detail here: https://rvm.io/packages/zlib/
There’s now a link in the tutorial to the page that describes RVM’s resolution.
Thanks for posting your solution!
It is really important that you make sure none of the debian ruby or ruby-rvm packages are installed before following these steps.
If they were make sure to uninstall them all with the apt-get --purge option. sudo apt-get remove ruby-rvm --purge
If you do not do this then the configuration file from the broken version included in the deb package will cause rvm to fail.
Just to let you know, I was going through this tutorial and noticed a typo in one of the commands. In the last command of step 1, you don’t need rvm or sudo for that command. It’s just installing packages from apt-get.
Hey,
For system libraries its best to install them as root and then install RVM under a specific user so that there isn’t an overlap with the system ruby binary which a lot of other applications such as puppet may depend on.
Thanks
Oh ok, I understand now. I’m just setting up a test server anyways (on the 24-hour trial). When I setup the actual production server, I’ll be sure to install rvm under a separate user.
thanks