Nginx

使用 Brew 和 RVM 在 MacOS X 中安裝乘客

  • February 26, 2011
#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;   
  }                  
}                    

寶石文件

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 davinci.dev

我得到這個錯誤:

http://davinci.dev:8081/

http://github.com/nmerouze/machinist_mongo.git(在 machinist2 處)未檢出。請執行bundle install

該 gem 安裝在 gemset DaVinci 中。我確實執行了捆綁安裝。它已安裝,但乘客沒有找到它。如果我刪除了那個 gem,那麼我會得到相同的錯誤,但會出現另一個 gem。等等等等。因此,Passenger 沒有找到寶石組。我可以使用rails s執行該項目。

我已經花了大約 4 個小時,但沒有找到 F###### 錯誤。你看出什麼不對了嗎?

用 rvm get head 解決。似乎有一個錯誤或某些東西沒有保存 gemset 的“受信任”狀態。

引用自:https://serverfault.com/questions/240617