Ruby 1.9, mysql, Phusion Passenger, and rails on Ubuntu

Here are some gotchas when trying to install Ruby on Rails on Ubuntu using Ruby 1.9, mysql, and Passenger (mod_rails).

The mysql gem fails.
In particular, running


gem install mysql

will fail with something like this:


gem install mysql
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
[...]
mysql.c:6:21: error: version.h: No such file or directory
[...]
make: *** [mysql.o] Error 1

This is because the official mysql gem has not yet been updated to mysql-ruby 2.8.1, which supports Ruby 1.9. Install mysql-ruby using the instructions from the author here: http://tmtm.org/mysql/ruby/README.html. Warning: I could not get the tests (ruby ./test.rb) to work, but it seemed to install fine. kwatch also provides an updated gem here: http://www.rubyflow.com/items/1631.

libopenssl-ruby will not be found by Passenger.
Passenger will think libopenssl-ruby has not been installed even after successfully running apt-get install libopenssl-ruby. This occurs if Ruby was built from source (which I do because the Ubuntu packaged Ruby 1.9 looks like an old version). Follow the instructions here: http://groups.google.com/group/phusion-passenger/browse_thread/thread/a496dd1e5a1273b3/9f7da032208a8713 to fix this. Namely:


cd /usr/local/src/ruby-1.9.1/ext/openssl (or whatever)
sudo ruby extconf.rb
make
make install