Nginx – Installing Passenger in MacOS X using Brew and RVM

nginxphusion-passengerruby-on-railsrvm

#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 is configured:

127.0.0.1 davinci.dev

And I get this error:

http://davinci.dev:8081/

http://github.com/nmerouze/machinist_mongo.git (at machinist2) is not checked out. Please run bundle install

That gem is installed in the gemset DaVinci. I did run bundle install. It is installed, but passenger doesn't find it. If I remove that gem, then I get the same errors but with another gem. And so on and so on. So Passenger is not finding the gemset. I can run the project with rails s.

I already spend like 4 hours and I don't find the F###### error. Do you see something wrong?

Best Answer

Solved with rvm get head. It seems there was a bug or something that wasn't saving the gemset 'trusted' status.

Related Topic