Ruby on Rails - Fresh install on Fedora 16

November 29, 2011

I just did a "nuke it from orbit and do a fresh install" of Fedora 16. So I need to start from scratch and get rails up and running. As usual, I am unsure of whether to use yum or gem to get various things -- so I just guess! My first step is:

yum install rubygem-rails
This pulls in 38 packages, including ruby-devel, and gives me rails 3.0.10. In anticipation of next installing passenger, I do:
yum install httpd-devel
This gives me apache 2.2.21, now I feel brave enough to do:
gem install passenger
passenger-install-apache2-module
The passenger gem goes in painlessly, and the passenger-install script is a nice interactive gizmo that compiles a lot of stuff and takes you by the hand fiddling with the apache config file. This is building passenger 3.0.11 by the way.

What I do is to put the generic passenger lines into /etc/httpd/conf.d/passenger.conf like so:

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.11
PassengerRuby /usr/bin/ruby
Then I restart apache and see that it doesn't get ugly (it doesn't). I have the virtual host lines in my httpd.conf file from the old days (but commented out since I didn't have rails set up).

A side note: passenger is great!. All I need to set up my applications with it is the 3 line file above in the conf.d directory and some simple virtual host setup in the apache httpd.conf file. No extra services or tricky nonsense.

Now, when I use a browser to access the first rails application, I get a nice traceback from passenger telling me that activesupport cannot be found. Actually what it is telling me is that activesupport 3.0.7 cannot be found (my new install has 3.0.10 versions of activesupport, activerecord, activeresource, and activemodel, all installed via yum. I go to my application (/u1/rails/micros) and edit the gemfile to tell it to use rails 3.0.10 rather than the 3.0.9 it was using. Then I do:

bundle update.
This fails for some obscure reason, but the last things I see it doing is looking for mysql_query(), so my guess is to install these packages that I thought I might have needed:
yum install mysql-devel ruby-mysql
And that did it, the bundle update works now.

Now when we try the application, we get:

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
The thing to do now is:
yum install mysql-server
systemctl restart mysqld.service
This gives me mysql 5.5.17. When I try the application, I get:
Access denied for user ''@'localhost' to database 'micros_development'
This would be because I have not yet copied the files for the old database!! They are in /var/lib/mysql (as specified by /etc/my.cnf), so for each application I copy 3 directories full of files (micros_development, production, and test). All of my files that really matter are in the development directory (I am a bad boy!).

This does not quite do it though -- I need the mysql user stuff to be migrated, and mysql is quite upset with what I just did, so ...

I make a tarball of /var/lib/mysql from my old system disk, replace the contents of /var/lib/mysql on my new system with this, and voila! Mysql starts up without complaint and my application now works.

A side note. I can now use the mainstream version of will_pagniate (3.0.2).

All of this took maybe 1.5 hours.


Feedback? Questions? Drop me a line!

Ruby on Rails notes / tom@mmto.org