Installing RVM, Ruby on Rails, and Passenger on Ubuntu

1
Want create site? Find Free WordPress Themes and plugins.

This install was using Ubuntu Precise 12.04 LTS, RVM 1.21.11, Ruby 2.0, and Rails 4, and Phusion Passenger.

First things first. This was a fresh install on AWS so let’s get up to date and install some packages needed for Apache2 / Passenger:

 sudo apt-get update
 sudo apt-get upgrade
 sudo ntpdate pool.ntp.org
 sudo apt-get install apache2-mpm-worker apache2-threaded-dev libapr1-dev libaprutil1-dev libcurl4-openssl-dev gawk  g++  gcc make  libc6-dev  libreadline6-dev  zlib1g-dev  libssl-dev  libyaml-dev  libsqlite3-dev  sqlite3  autoconf  libgdbm-dev  libncurses5-dev  automake  libtool  bison  pkg-config  libffi-dev

With that out of the way, let’s start installing rvm. The process has become much more streamlined in recent releases, but some of these improvements aren’t easily compatible with Ubuntu (or, more specifically, sudo).

 sudo -s  curl https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable  source /etc/profile.d/rvm.sh  usermod -G rvm ubuntu  exit

At this point RVM is installed and you should be logged in as your user (not as root). You may need to logout and log back in.  As a multi-site install RVM should have been installed to /usr/local/rvm. Let’s do some sanity checks.

The command:

 which rvm

should return

 /usr/local/rvm/bin/rvm

and the command

 type rvm |head -1

should return

 rvm is a function

With RVM installed we can install Ruby:

 rvm install 2.0 --with-openssl-dir=/usr gem install mysql2 passenger

And then Passenger for Apache:

 rvmsudo passenger-install-apache2-module

There will be a good deal of output as Passenger runs it’s make, but you need to pay special attention to three lines at the very end. They’ll look something like:

 LoadModule passenger_module /usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.10/buildout/apache2/mod_passenger.so PassengerRoot /usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.10 PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-2.0.0-p247/ruby

Copy them to a text file for use in a few minutes.

 cd /etc/apache2/sites-available
 sudo vi yourapp.conf
 <VirtualHost *:80>   ServerAdmin [email protected]   DocumentRoot /var/www/yourapp/public   ServerName yourservername   <Directory /var/www/yourapp>     AllowOverride all     Options -MultiViews   </Directory>   ErrorLog /var/log/apache2/yourapp/error.log   CustomLog /var/log/apache2/yourapp/access.log common </VirtualHost>

Next we need to make the directories we just referenced. The directories I use here are my preference, and I believe they lead to good organization. For example, if you use logrotate and have ~15 sites running on a server, having separate log directories will make locating the log file you need more intuitive for you and anyone else using the system. And if you don’t use logrotate I admire your sed/awk skills. That said, they’re arbitrary. Use whatever structure works best for you.

 sudo mkdir /var/www/yourapp sudo mkdir /var/log/apache2/yourapp

Almost done. We need to tell Apache about Passenger.

 cd /etc/apache2/mods-available sudo vi passenger.load

Paste in the three lines you copied from the Passenger install output:

 LoadModule passenger_module /usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.10/buildout/apache2/mod_passenger.so PassengerRoot /usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.10 PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-2.0.0-p247/ruby

and save the file.

Almost there. We’ve told Apache about the new site and the new Passenger module, but we need to tell Apache we’d like to use them.

 sudo a2enmod passenger
 sudo a2ensite yourapp.conf

Deploy your app to /var/www/yourapp and restart apache:

 sudo service apache2 restart
Did you find apk for android? You can find new Free Android Games and apps.

You might also like More from author

  • sac14

    i am running a Kali linux machine.
    trying to install Phusion Passenger….

    Unable to run this command:-

    passenger-install-apache2-module

    any help plz?