Aug 22 2010

Install RVM, Passenger, Nginx and Rails 3 on Ubuntu Lucid Lynx

RVM Rails3 Ubuntu Ruby192 | comments

This has been a problem encountered by several developers including myself:

Getting RVM, Passenger and Rails3 to work

Here's a quick and short post. Supposing you already have updated Ubuntu and have Ruby installed. These are the only commands you should need:

              
              rvm install 1.9.2
              
              rvm 1.9.2 --passenger
              
              rvm 1.9.2
              gem install passenger
              
              rvmsudo passenger-install-nginx-module
              
              #use rvm by default
              rvm 1.9.2-preview3 --default
              
              #edit the nginx config file. mine is on /opt/nginx/conf/nginx.conf. just change username 
              
              passenger_root /home/username/.rvm/gems/ruby-1.9.2-preview3/gems/passenger-2.2.15;
              passenger_ruby /home/username/.rvm/bin/passenger_ruby;
              
              #reboot if you can. I recommend rebooting over restarting/stopping and starting nginx server. reboot was actually the fix I needed after following all the steps above. 
              
              sudo reboot 
              
              
              #.rvmrc file on your Rails 3 app should contain. this may be optional but in case you've set a different ruby version, this helps. 
              
              if [[ -s "~/.rvm/environments/ruby-1.9.2-preview3" ]] ; then
                . "~/.rvm/environments/ruby-1.9.2-preview3"
              else
                rvm --create use  "ruby-1.9.2-preview3"
              
              
              
              

If nothing works for you. Check your path, your ruby version and check whether bundler is installed.

How to installed bundler for Rails 3:

              
              gem install bundler --pre
              
              

Most gems for Rails 3 require "--pre" by the way.

Installing gems

              
              cd app/dir && bundle install
              
              

It's that simple. But something failed. I use mysql and pg gem. I use mysql gem for test and development environment because they work better for testing. But I use postgresql for production and staging. Mysql gem was not installed by bundler. You have to run this:

              gem install mysql -- --with-mysql-config=/usr/bin/mysql_config
              

Hope this helped someone.