Step by Step - Install RVM, Rails, Passenger and Nginx on Ubuntu 12.04
For installing RVM, Ruby , Rails please follow below link:
http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/
Once you have installed everything you need for development, let's see how to deploy our web application on Nginx with Passenger.
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7
sudo apt-get install apt-transport-https ca-certificates
Create a file /etc/apt/sources.list.d/passenger.list and insert following lines.
deb https://oss-binaries.phusionpassenger.com/apt/passenger precise main
Secure passenger.list and update your APT cache
sudo chown root: /etc/apt/sources.list.d/passenger.list sudo chmod 600 /etc/apt/sources.list.d/passenger.list sudo apt-get update
sudo apt-get install nginx-extras passenger
Edit /etc/nginx/nginx.conf and uncomment passenger_root and passenger_ruby.
sudo service nginx restart
Add a server virtual host entry to your Nginx configuration file. The virtual host’s root must point to your Ruby on Rails application’s public folder. You can find config file at /etc/nginx/sites-enabled. You can either add server entry to default file or create new file.
http { ... server { listen 80; server_name localhost; root /webapps/mycook/public; passenger_enabled on;
passenger_ruby /home/username/.rvm/rubies/ruby-2.0.0-p353/bin/ruby;
passenger_app_env development; } ... }
Replace server_name with appropriate domain name/public IP.
If your web application using RVM gemset (using .ruby-version) then you need to use that as passenger_ruby. To find which one your web application is using, go to application directory and run below command
This will give output something like
/opt/passenger/bin/passenger-config or /usr/bin/passenger-config
Now add --ruby-command to it and run
/opt/passenger/bin/passenger-config --ruby-command
passenger-config was invoked through the following Ruby interpreter: Command: /usr/local/rvm/wrappers/ruby-1.9.3-p392/ruby Version: ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin12.2.1] To use in Apache: PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p392/ruby To use in Nginx : passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.3-p392/ruby To use with Standalone: /usr/local/rvm/wrappers/ruby-1.9.3-p392/ruby /opt/passenger/bin/passenger start
Use the respective path given in above.
http://www.modrails.com/documentation/Users%20guide%20Nginx.html