Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

http://thekindofme.wordpress.

com/2010/10/24/rails-3-on-ubuntu-10-10-with-rvm-passenger-and-nginx/

theKindOfMe
October 24, 2010
Rails 3 on Ubuntu 10.10 with RVM, Passenger and Nginx

Filed under: Uncategorized — Tags: linux, rails, ubuntu — yasi8h @ 1:09 am

This covers setting up a Ubuntu 10.10 box to run rails 3 on production. Please
notice it only focus on installing and setting up things mentioned in the title.
However there are other things that you should configure and setup when
deploying a application to production (like ntpd for example).

Installing RVM

We will need git before we can get started.


1 sudo apt-get install git

Install rvm according to the official guide.


1 bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )

add
1 [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a
shell session.

to your .bashrc.

Once you edit your bashrc file execute the following to load rvm without logging
out and back in
1 source ~/.rvm/scripts/rvm

Just to be safe check wether rvm is a function, which is what it should be.
1 type rvm | head -n1

Install ruby 1.9.2

See what you get out of rvm notes. you will need to install some stuff before you
can compile ruby.
1 aptitude install build-essential bison openssl libreadline5 libreadline5-dev curl git-core
zlib1g zlib1g-dev libssl-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev

Rails 3 on Ubuntu 10.10 with RVM, Passenger and... 1 de 8


http://thekindofme.wordpress.com/2010/10/24/rails-3-on-ubuntu-10-10-with-rvm-passenger-and-nginx/

libmysqlclient-dev

The above packages covers some common stuff. It should be enough to get you
started. However depending on what gems you want to install you might need to
install additional dependencies.
1 rvm install 1.9.2

Set 1.9.2 as the default


1 rvm use 1.9.2 --default

Passenger

Install passenger as instructed in rvm documentation


http://rvm.beginrescueend.com/integration/passenger/
1 rvm 1.9.2 --passenger
2 rvm 1.9.2
3 gem install passenger
4 rvmsudo passenger-install-nginx-module

Let passenger downland and install nginx for you.

Modify /opt/nginx/conf/nginx.conf (thats the default location).

‘For Nginx users, replace the passenger_ruby line with:’


1 passenger_ruby /home/wayne/.rvm/bin/passenger_ruby;

Add a block like this to host your RoR site


1 server {
2 listen 80; #the server will be running on this port
3 server_name www.yourhost.com;
4 root /home/deployer/your_rails_project/public; # <--- be sure to point to 'public'!
5 passenger_enabled on;
6 }

Nginx init script

From: http://github.com/jnstq/rails-nginx-passenger-ubuntu
1 cd
2 git clone git://github.com/jnstq/rails-nginx-passenger-ubuntu.git
3 sudo mv rails-nginx-passenger-ubuntu/nginx/nginx /etc/init.d/nginx
4 sudo chown root:root /etc/init.d/nginx

More information on http://wiki.nginx.org/Nginx-init-ubuntu

MySQL

Rails 3 on Ubuntu 10.10 with RVM, Passenger and... 2 de 8


http://thekindofme.wordpress.com/2010/10/24/rails-3-on-ubuntu-10-10-with-rvm-passenger-and-nginx/

1 sudo apt-get install mysql-client mysql-server

Get the source for your rails app. unzip it in your home folder (or where ever you
want to. But be sure to edit the nginx config as appropriate).
1 cd to-your-rails-app-folder
2 bundle install
3 rake db:setup RAILS_ENV=production
4
5 sudo /etc/init.d/nginx restart

Thats it!

Comments (3)

3 Comments »

1.

the following command did not work for me:


source ~/.rvm/scripts/rvm

instead:
source ~/.rvm/src/rvm/scripts/rvm

so if you get any message that it cannot find the rvm script or that it thinks
rvm is a directory, please traverse the path and find out exactly where curl
places the script files.

Comment by vish — November 11, 2010 @ 12:09 am

Reply

RVM must have changed its directory structure. Yep thats the case.

Comment by yasi8h — November 11, 2010 @ 3:15 pm

Reply

2.

I would do this first:

- this is closer to what you would do after you have installed Ubuntu and
contains CURL which you need to install RVM.

aptitude install build-essential bison openssl libreadline5 libreadline5-dev

Rails 3 on Ubuntu 10.10 with RVM, Passenger and... 3 de 8


http://thekindofme.wordpress.com/2010/10/24/rails-3-on-ubuntu-10-10-with-rvm-passenger-and-nginx/

curl git-core zlib1g zlib1g-dev libssl-dev libsqlite3-0 libsqlite3-dev sqlite3


libxml2-dev libmysqlclient-dev

Comment by vish — November 11, 2010 @ 12:14 am

Reply

RSS feed for comments on this post.

Leave a comment

Name (required)

E-mail (required)

Website

Submit Comment

Notify me of follow-up comments via email.

Subscribe by email to this site

Search

Pages
About

Recent Posts

Rails 3 on Ubuntu 10.10 with RVM, Passenger and... 4 de 8


http://thekindofme.wordpress.com/2010/10/24/rails-3-on-ubuntu-10-10-with-rvm-passenger-and-nginx/

Retrieving DISTINCT results with Active Record on Complex Queries


Rails 3 on Ubuntu 10.10 with RVM, Passenger and Nginx
Getting Started with EC2
Task Scheduling with Cron, RVM and Rails
Rooting your HTC Desire and Custom ROMs: Notes and Links

Tags

.net .netcf art asp.net asp.net mvc bug code debian logo firefox games
greasemonkey hardware javascript jQuery linux movies music mvc netbeans
networking notes oo p2p paranoia perl personal photos qBittorrent rails rant rants recursion

rss blogger ruby ruby on rails slt adsl svn swirls tips torrenting ubuntu
ubuntu. linux vss windows winforms

Linkedin

Fork me on github

last.fm

Rails 3 on Ubuntu 10.10 with RVM, Passenger and... 5 de 8


http://thekindofme.wordpress.com/2010/10/24/rails-3-on-ubuntu-10-10-with-rvm-passenger-and-nginx/

Flickr Photos

More Photos

visitors

Tweets
SL Police is a bloody joke, when they publish pics of 'porn actresses'. I
guess no minister have invested in the porn industry yet.... 9 hours ago
thinking of using the compartment for the hydration pack in the
backpack for the laptop. good that it have a extended apple care plan ;)
9 hours ago
@dinuks yeah the streets are so packed like private bus at home ;-)
11 hours ago
When people say little india can be crowded in the weekends they
really mean it. 11 hours ago
Wish the rain will stop. Is a sunday. Why does it have to rain on a
sunday. 13 hours ago

Rails 3 on Ubuntu 10.10 with RVM, Passenger and... 6 de 8


http://thekindofme.wordpress.com/2010/10/24/rails-3-on-ubuntu-10-10-with-rvm-passenger-and-nginx/

Archives
November 2010
October 2010
September 2010
August 2010
July 2010
May 2010
April 2010
February 2010
January 2010
November 2009
October 2009
August 2009
July 2009
April 2009
March 2009
February 2009
January 2009
December 2008
November 2008
June 2008
April 2007
March 2007
February 2007
January 2007

Blogroll
ubuntu

Co Workers
ෙපාඩ්ඩාෙග් ෙලා්කය

Meta
Register
Log in
Entries RSS
Comments RSS
WordPress.com

Rails 3 on Ubuntu 10.10 with RVM, Passenger and... 7 de 8


http://thekindofme.wordpress.com/2010/10/24/rails-3-on-ubuntu-10-10-with-rvm-passenger-and-nginx/

Blog at WordPress.com.

Rails 3 on Ubuntu 10.10 with RVM, Passenger and... 8 de 8

You might also like