Apache 2、Passenger 3 和 RVM 设置

发布于 2024-12-23 07:09:19 字数 843 浏览 0 评论 0 原文

我想使用 Apache2 + Passenger3 + RVM 设置 RoR 服务器,这些是我的配置

# Passenger Apache Integartion
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.8.7-p352@global/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.8.7-p352@global/gems/passenger-3.0.11
PassengerRuby /usr/local/rvm/wrappers/ruby-1.8.7-p352@global/ruby

,这是我的 .rvmrc

if [[ -s "/usr/local/rvm/gems/ruby-1.8.7-p352@myapp" ]] ; then
  . "/usr/local/rvm/gems/ruby-1.8.7-p352@myapp"
else
  rvm --create use  "1.8.7@myapp"
fi

myapp gemset 已创建并包含所有必需的 gem,所以现在在 environment.rb 文件中,我加载一个 gem 文件 require require 'postmark-rails' 它显示错误 no such file to load -- postmark-rails (MissingSourceFile) 意味着它没有加载正确的宝石集。怎么算出来呢?

I want to setup a RoR server with Apache2 + Passenger3 + RVM, These are my configurations

# Passenger Apache Integartion
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.8.7-p352@global/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.8.7-p352@global/gems/passenger-3.0.11
PassengerRuby /usr/local/rvm/wrappers/ruby-1.8.7-p352@global/ruby

and here is my .rvmrc

if [[ -s "/usr/local/rvm/gems/ruby-1.8.7-p352@myapp" ]] ; then
  . "/usr/local/rvm/gems/ruby-1.8.7-p352@myapp"
else
  rvm --create use  "1.8.7@myapp"
fi

myapp gemset is created and contains all required gems, so now in environment.rb file i load a gem file require require 'postmark-rails' And it is showing the error no such file to load -- postmark-rails (MissingSourceFile) Means it is not loading the proper gemset. How to figure it out?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纸短情长 2024-12-30 07:09:19

.rvmrc 文件无法正常工作。所以我搜索并找到了创建 .rvmrc 文件的正确方法。

在目录 home 中使用此命令 rvm 1.8.7@myapp --rvmrc --create

这将创建正确的 .rvmrc 文件。然后将此代码放入 Rails 2 应用程序

if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
  begin
    rvm_path     = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
    rvm_lib_path = File.join(rvm_path, 'lib')
    $LOAD_PATH.unshift rvm_lib_path
    require 'rvm'
    RVM.use_from_path! File.dirname(File.dirname(__FILE__))
  rescue LoadError
    # RVM is unavailable at this point.
    raise "RVM ruby lib is currently unavailable."
  end
end

和 Rails 3

if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
  begin
    rvm_path     = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
    rvm_lib_path = File.join(rvm_path, 'lib')
    $LOAD_PATH.unshift rvm_lib_path
    require 'rvm'
    RVM.use_from_path! File.dirname(File.dirname(__FILE__))
  rescue LoadError
    # RVM is unavailable at this point.
    raise "RVM ruby lib is currently unavailable."
  end
end

# If we're using a Bundler 1.0 beta
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
require 'bundler/setup'

# Or Bundler 0.9...
if File.exist?(".bundle/environment.rb")
  require '.bundle/environment'
else
  require 'rubygems'
  require 'bundler'
  Bundler.setup
end

config/setup_load_paths.rb代码取自 http://blog.ninjahideout.com/posts/the-path-to-better-rvm-and-passenger-integration。它解决了我的问题,乘客与 RVM 配合得很好。

The .rvmrc file was not working well. So i searched out and find the proper way to create the .rvmrc file.

in the directory home used this command rvm 1.8.7@myapp --rvmrc --create

This create the proper .rvmrc file. Then put this code in config/setup_load_paths.rb for Rails 2 app

if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
  begin
    rvm_path     = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
    rvm_lib_path = File.join(rvm_path, 'lib')
    $LOAD_PATH.unshift rvm_lib_path
    require 'rvm'
    RVM.use_from_path! File.dirname(File.dirname(__FILE__))
  rescue LoadError
    # RVM is unavailable at this point.
    raise "RVM ruby lib is currently unavailable."
  end
end

and For Rails 3

if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
  begin
    rvm_path     = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
    rvm_lib_path = File.join(rvm_path, 'lib')
    $LOAD_PATH.unshift rvm_lib_path
    require 'rvm'
    RVM.use_from_path! File.dirname(File.dirname(__FILE__))
  rescue LoadError
    # RVM is unavailable at this point.
    raise "RVM ruby lib is currently unavailable."
  end
end

# If we're using a Bundler 1.0 beta
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
require 'bundler/setup'

# Or Bundler 0.9...
if File.exist?(".bundle/environment.rb")
  require '.bundle/environment'
else
  require 'rubygems'
  require 'bundler'
  Bundler.setup
end

The code is taken from http://blog.ninjahideout.com/posts/the-path-to-better-rvm-and-passenger-integration. It solved my the problem and the passenger is working very well with rvm.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文