In this post you will find detail steps to set up a production server for a Rails 3 application with Ruby 1.9.2 + Phusion Passenger + Nginx on Ubuntu 10.04 LTS.
Make sure Ubuntu 10.04 LTS is installed. Do the ssh login on server and follow the below steps:
apt-get update
apt-get -y install build-essential zlib1g zlib1g-dev libxml2 libxml2-dev libxslt-dev
apt-get git-core
apt-get -y install curl wget
Now you are ready to install the latest Ruby 1.9.2
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p0.tar.gz
Extract the tar and run the configure, make and make install commands as follows:
tar -xvf ruby-1.9.2-p0.tar.gz
./configure
make
make install
This will install ruby 1.9.2, you can confirm this by running:
ruby -v
Next step is to install rails, now when you install gems on a production server you probably do not want to install any documentation along with it. To skip documentation by default when you install gems create/edit the .gemrc file in your home directory:
---
:update_sources: true
:sources:
- http://gems.rubyforge.org/
- http://gems.github.com
:benchmark: false
:bulk_threshold: 1000
:backtrace: false
:verbose: true
gem: --no-ri --no-rdoc
Ready to install rails now with the following command:
gem install rails
Now, to install Phusion Passenge and Nginx:
gem install passenger
passenger-install-nginx-module
When I ran passenger-install-nginx-module command, I got the following error:
OpenSSL support for Ruby… not found
Openssl package needed, to install this follow the below steps:
cd /usr/local/src/ruby-1.9.2-p0/ext/openssl
ruby extconf.rb
make
make install
You can install either using this sudo apt-get install openssl
All steps are done! Nginx is installed in “/opt/nginx”
To start Nginx type this command “/opt/nginx/sbin/nginx” and to stop type “kill nginx”