Categories: Ubuntu | Installation and Setup | Apache | Ruby | RubyGems
Contents |
Recently it has become much easier to setup a RubyOnRails stack utilizing a Ruby gem called Passenger. Passenger will compile an apache2 module which will allow you to configure a RubyOnRails virtualhost the same way as you would any other site.
Unfortunately, on Ubuntu 8.10 Intrepid, the RubyGems package is broken. It will give you random code errors and leave you pulling out your hair. Not to worry, this step by step process will get you up and running with a full Rails stack using Passenger in no time.
The following steps assume you are running the commands as root.
# apt-get update && apt-get dist-upgrade # apt-get install build-essential subversion apache2-mpm-prefork apache2-prefork-dev # apt-get install ruby ruby1.8-dev ri irb libopenssl-ruby mysql-server
# cd /usr/src # wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz # tar zxvf rubygems-1.3.1.tgz # cd rubygems-1.3.1 # ruby setup.rb # ln -s /usr/bin/gem1.8 /usr/bin/gem
# gem install rails rake passenger # rails -v
Here we tell passenger to compile and install the apache2 module
# passenger-install-apache2-module
Paste the following at the end of /etc/apache2/apache2.conf
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.3/ext/apache2/mod_passenger.so PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.3 PassengerRuby /usr/bin/ruby1.8
Finally, we restart apache2.
# /etc/init.d/apache2 restart
Now you should be able to create a standard virtualhost pointing to the public directory of your app and Apache2 will detect that it is Rails.