How can I upgrade the Ruby version on Passenger?

2

How can I uprgade the Ruby version installed on my passenger module for Apache?

I on Debian 7 and it's running Ruby 1.9.1 but I want 2.2.0

Felix

Posted 2015-03-04T08:01:07.703

Reputation: 131

Can you please edit your question to indicate what OS are you using? Linux I assume, but it would help clarify why you have Ruby 1.9.1 installed; sounds like Ubuntu, right? Also I’ve installed Passenger for Ruby, but I am not sure that installing Passenger would change the Ruby version in and of itself. – JakeGould – 2015-03-04T08:15:19.830

I'm using debian 7, sorry for missing this. – Felix – 2015-03-04T08:46:27.367

I edited your question to add those details. Like I said in my first comment, you should have edited your question to indicate what OS are you using. Similarly, can you edit your question to explain the exact commands you used to install Passenger and Ruby? – JakeGould – 2015-03-04T19:47:39.137

Answers

2

First you have to install a newer Ruby version. You can do that using rbenv with ruby-build or RVM. I've found the former to be a little more simple to use and less intrusive. Simply install rbenv and ruby-build according to the documentation, then:

rbenv install 2.2.0

Once you've installed it, set your global Ruby to 2.2.0 (or whatever the name of the Ruby is you installed):

rbenv global 2.2.0

You need to reload your shell for this to take effect. Note that which ruby will only give you the path to a so-called shim, not the actual Ruby interpreter. To find out the path, simply modify the line below, changing 2.2.0 to whatever version you installed.

Now, in the Passenger configuration, change the PassengerRuby option for your virtual host, e.g.

PassengerRuby /usr/local/rbenv/versions/2.2.0/bin/ruby

Reload the server, and you should be done.

slhck

Posted 2015-03-04T08:01:07.703

Reputation: 182 472

is it the same unter debian 7? – Felix – 2015-03-04T08:47:31.327

This is a decent answer which I upvoted, but before I truly understood the philosophy of RVM and such, I defaulted to the repository packages and then source code installs. So this answer is good but assumes a lot. Something to keep in mind. – JakeGould – 2015-03-04T08:52:29.777

when I installed passenger for apache2 the ruby installations comes automatically with the installation. isn't there an esier way to do the ruby update? – Felix – 2015-03-04T08:56:50.877

@Felix The Ruby versions that come with distributions are often not the latest ones, so you're unlikely to find an official 2.2.0 that you can use directly with apt-get (but there are some PPAs). The generally recommended way to get a recent Ruby is to use rbenv or RVM, these days. Compiling from source yourself is also possible, but requires a little more knowledge about Linux in general, and a bit more effort when trying to switch between multiple versions.

– slhck – 2015-03-04T09:03:31.143

@JakeGould I've been programming Rails since several years. I've read best practices and lots of tutorials, and I've rarely seen people recommend source code based installs without Ruby version managers. I understand that it's a straightforward approach, but it can be overwhelming. At least to me it was like that. – slhck – 2015-03-04T09:50:45.133

@slhck I’m not saying installing from source is the best way to upgrade Rails. I am just saying when I was a novice I first went from the basic repository install of Ruby, to the source code install of Ruby for an upgrade and then to a custom PPA of Ruby for upgrades and—only when I fully understood why—I moved to RVM. RVM or rbenv is definitely the way to go, but that does not mean this original poster went down that route. – JakeGould – 2015-03-04T19:46:31.920