使用 Brew 和 RVM 在 MacOS X 中安装 Passenger

使用 Brew 和 RVM 在 MacOS X 中安装 Passenger
#Install RVM    
bash <<( curl http://rvm.beginrescueend.com/releases/rvm-install-head )

#Install ruby 1.9.2
rvm install 1.9.2

# Set as default
rvm --default 1.9.2 

# Install passenger in the global gemset
rvm @global gem install passenger       

# Install Nginx                                  
brew install nginx --with-passenger

cp /usr/local/Cellar/nginx/0.8.54/org.nginx.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/org.nginx.plist        

# Decompress the source of Nginx.
cd $HOME/Library/Caches/Homebrew
tar xvf nginx-0.8.54.tar.gz                       

# Now install the nginx module
passenger-install-nginx-module

# Chose to configure to customise your own Nginx installation

# The source code for nginx is here:
/Users/Nerian/Library/Caches/Homebrew/nginx-0.8.54                             

# Chose to install nginx to:
/usr/local/Cellar/nginx/0.8.54/sbin

# Click intro in the next two questions.

# At the end of the install it says that it modified nginx config file. I don't use that file. I Edit /usr/local/etc/nginx/nginx.conf and add the snippet that the passenger install outputed.

http {
  ...     
  passenger_root /Users/Nerian/.rvm/gems/ruby-1.9.2-p180@global/gems/passenger-3.0.3;
  passenger_ruby /Users/Nerian/.rvm/wrappers/ruby-1.9.2-p180/ruby;
  ...
}    

# Install rails

rvm gem install rails


Configure a Rails 3 Project

# .rvmrc

if [[ -s "/Users/Nerian/.rvm/environments/ruby-1.9.2-p180@DaVinci" ]] ; then
  . "/Users/Nerian/.rvm/environments/ruby-1.9.2-p180@DaVinci"
else
  rvm --create use  "ruby-1.9.2-p180@DaVinci"
fi


# Set up load path in your Rails 3 project. This is config/setup_load_paths.rb

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

nginx.conf

http {
    include       mime.types;
    default_type  application/octet-stream;
    access_log /tmp/nginx-access.log;

    passenger_root /Users/Nerian/.rvm/gems/ruby-1.9.2-p180@global/gems/passenger-3.0.3;
    passenger_ruby /Users/Nerian/.rvm/wrappers/ruby-1.9.2-p180/ruby;

    sendfile        on;
    keepalive_timeout  65;

#gzip  on;         

server {
      listen 8081;
      server_name davinci.dev;
      root /Users/Nerian/NetBeansProjects/DaVinci/public;
      passenger_enabled on;
      rails_env development;   
   }                  
}                    

Gemfile

source 'http://rubygems.org'

gem 'rails', '3.0.4'                                                     
gem "mongoid", "2.0.0.rc.7"
gem "bson_ext", "~> 1.2"
gem 'launchy'

group :development, :test do
  gem 'rspec-rails'
  gem 'machinist_mongo', :require => 'machinist/mongoid', :git => 'http://github.com/nmerouze/machinist_mongo.git', :branch => 'machinist2'
  gem 'steak'
  gem 'capybara'
  gem 'spork', '~> 0.9.0.rc'
  gem "fuubar"  
end

/etc/hosts 配置如下:

127.0.0.1 达芬奇

我收到此错误:

http://davinci.dev:8081/

http://github.com/nmerouze/machinist_mongo.git(在 machinest2)未签出。请运行bundle install

该 gem 安装在 DaVinci gemset 中。我运行了 bundle install。它已安装,但 Passenger 找不到它。如果我删除该 gem,则会得到相同的错误,但使用的是另一个 gem。等等等等。所以 Passenger 找不到 gemset。我可以使用轨道

我已经花了 4 个小时,却没有发现 F###### 错误。您发现什么问题了吗?

答案1

使用 rvm get head 解决了这个问题。似乎有一个错误或某些东西没有保存 gemset 的“受信任”状态。

相关内容