简体   繁体   English

使用Nginx的乘客找不到导轨2.3.8宝石

[英]Passenger with Nginx cannot find rails 2.3.8 gem

I have been trying to setup nginx with passenger for a few days now and keep running into problems. 我一直在尝试与乘客设置Nginx几天,并一直遇到问题。 When I go to my Rails application with my browser it says: Missing the Rails 2.3.8 gem. Please gem install -v=2.3.8 rails, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed. 当我使用浏览器进入Rails应用程序时,它显示: Missing the Rails 2.3.8 gem. Please gem install -v=2.3.8 rails, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed. Missing the Rails 2.3.8 gem. Please gem install -v=2.3.8 rails, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.

If I type gem list in my terminal it shows: rails (3.0.0, 2.3.8, 2.3.5) 如果我在终端中输入gem list ,它将显示: rails (3.0.0, 2.3.8, 2.3.5)

What is funny is that passenger will find my ruby gems just fine when I use it with Apache on the same machine! 有趣的是,当我在同一台机器上将Apache与Apache一起使用时,乘客会发现我的红宝石宝石很好! But I would like to experiment with nginx because Apache is not doing what I want. 但我想尝试使用nginx,因为Apache并未执行我想要的操作。

The machine is Ubuntu 10.04 Server 该机器是Ubuntu 10.04 Server

  • which ruby Shows: /usr/local/bin/ruby (REE) which ruby显示的是: /usr/local/bin/ruby (REE)
  • These are the passenger directives in the nginx.conf: 这些是nginx.conf中的passenger指令:
    • passenger_root /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.15; passenger_ruby /usr/local/bin/ruby;

As a check, are you sure your passenger is installed in the correct version of ruby. 作为检查,您确定您的乘客安装了正确版本的红宝石。 basically 基本上

Both the rubies have separate gems meaning you have to install the other in one.. 这两个红宝石都有单独的宝石,这意味着您必须将另一个安装在一个宝石中。

Check in the /usr/local/lib/ruby/gems/1.8/gems Directory to see if rails 2.3.8 is present. 在/usr/local/lib/ruby/gems/1.8/gems目录中检查以查看是否存在rails 2.3.8。 You need to install it in the this ruby. 您需要将其安装在此红宝石中。

Both rubies will have separate gem bin files for installation.. 这两个红宝石都有单独的gem bin文件进行安装。

possibly /usr/bin/gem is for the system ruby and /usr/local/bin/gem is for your installation of REE / usr / bin / gem可能用于系统ruby,而/ usr / local / bin / gem则用于您的REE安装

@Nik Rishav is correct in that you have to be careful when installing Ruby Enterprise Edition (REE) along side the system Ruby. @Nik Rishav是正确的,因为在系统Ruby旁边安装Ruby Enterprise Edition(REE)时必须小心。 Installing REE incorrectly can cause some very strange things to happen. 错误地安装REE会导致发生一些非常奇怪的事情。

While Rails 3.0 could be the cause of your issues, my gut tells me your real issue is one missed step when installing REE. 尽管Rails 3.0可能是造成问题的原因,但我的直觉告诉我,真正的问题是安装REE时遗漏的一步。 But, just-in-case this doesn't work, a quick Google search will show you any number of good tutorials showing you how to host a Rails app with Phusion Passenger for Nginx . 但是,以防万一,这是行不通的,快速的Google搜索将为您显示许多不错的教程,向您展示如何使用Phusion Passenger for Nginx托管Rails应用 Well, let's give it a go, shall we! 好吧,让我们去吧,好吧!

REE runs fine alongside system Ruby, but you have to install it into its own directory. REE与系统Ruby一起运行良好,但是您必须将其安装到其自己的目录中。 For example: 例如:

/opt/ruby-enterprise-X.X.X/bin/ruby

Your other option is to only install REE, but this might not be an option for you. 您的另一个选择是仅安装REE,但这可能不是您的选择。 I suspect that when Nginx runs, it does find REE as you have specified it. 我怀疑当Nginx运行时,它确实会按照您指定的方式找到REE。 Did you install Passenger for Nginx from the REE stack? 您是否从REE堆栈中安装了Nginx的Passenger?

/opt/ruby-enterprise-X.X.X/bin/passenger-install-apache2-module

If you haven't, you might want to look into that. 如果没有,您可能需要调查一下。 I'll assume you did. 我假设你做到了。

From your description, it doesn't look like you have told REE where to find your gems. 从您的描述来看,您似乎并没有告诉REE在哪里可以找到您的宝石。 To do this, you need to set REE as the default Ruby Interpreter. 为此,您需要将REE设置为默认的Ruby解释器。 To do this, add an entry to the file /etc/environment . 为此,将一个条目添加到文件/ etc / environment中 On Ubuntu, the directory is /etc/environment . 在Ubuntu上,目录为/ etc / environment Add REE's bin directory to the PATH environment variable, like this: 将REE的bin目录添加到PATH环境变量中,如下所示:

PATH="/opt/ruby-enterprise-x.x.x/bin:/usr/local/sbin:/usr/local/bin"

Placing REE first in the PATH will set it as the default Ruby interpreter. 首先将REE放入PATH会将其设置为默认的Ruby解释器。

Then restart Nginx, like so: 然后重新启动Nginx,如下所示:

sudo /etc/init.d/nginx restart

Hopefully this helps. 希望这会有所帮助。 I've had my share of deployment issues and it truly can be frustrating. 我遇到了很多部署问题,这确实令人沮丧。 Wouldn't wish it on anyone...Good luck! 不想对任何人...祝你好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM