开发者

How to configure Rails to use different version of Ruby?

I'm trying to deploy my Rails 3.0.1 application which works with Ruby 1.9.2.

However, I noticed that Rails 1.8.7 is installed on the server.

What steps should I take to install Ruby 1.9.2 on the server, and force my application to 开发者_如何学Gouse it ?

I use Apache and Passenger.


I would recommend installing RVM and using that to set the version of Ruby that you want on the server.

Here's a rundown of its advantages in a production environment:

RVM allows users to deploy each project with its own completely self-contained and dedicated environment--from the specific version of ruby all the way down to the precise set of required gems to run the application. Having a precise set of gems also avoids the issue of version conflicts between projects, causing difficult-to-trace errors and hours of hair loss. With RVM, NO OTHER GEMS than those required are installed. This makes working with multiple complex applications where each has a long list of gem dependencies efficient. RVM allows us to easily test gem upgrades by switching to a new clean set of gems to test with while leaving our original set intact. It is flexible enough to even have a set of gems per environment or development branch--or even individual developer's taste!

It's very easy to setup and use, especially compared to managing the Ruby versions yourself. I've done both and I prefer RVM much more now. Once you have RVM installed, using Ruby 1.9.2 is as easy as:

rvm install 1.9.2
rvm use 1.9.2

And then you can check which version of Ruby your production environment is using with:

ruby -v


Assuming you use Apache, reinstall Passenger with

$ passenger-install-apache2-module

while having Ruby 1.9.2 active. If you use RVM just type rvm use 1.9.2 to make that version of Ruby active. Follow the on-screen instructions for how to modify your httpd.conf.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜