Tuesday, March 3, 2009

Migrating an RoR app from Ubuntu Feisty to CentOS 5.2 Part 1: Setting up mod_rails

Notes from migrating an app from an overloaded Ubuntu server box to a new, virgin centOS box. The app is a Rails app, with a postgres db, served up via mod_rails (passenger). The destination box has apache2 and Ruby 1.8.7 installed.


My app uses phusion passenger, which is fairly easy to install.

Steps:
(1) sudo gem install passenger
(2) I then needed to generate the apache mod for passenger.

sudo passenger-install-apache-2-module

This step told me the following:

* To install GNU C++ compiler: Please run yum install gcc-c++ as root. * To install OpenSSL support for Ruby: Please (re)install Ruby with OpenSSL support by downloading it from http://www.ruby-lang.org/. * To install Apache 2 development headers: Please run yum install httpd-devel as root.
Installing gcc-c++

sudo yum install gcc-c++, this was painless. Yum is installed by default on the version of centos I was migrating to (5.2)

Enabling Ruby with Open SSL

Unfortunately the company approved version of Ruby 1.8.7 did not include ext/openssl, so I needed to download, build, and install on my own.

(1) download source

wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p72.tar.gz

(2) untar, cd to extracted dir, and run ./configure
(3) make

At this point, you usually sudo make install, but I didn't want to re-install ruby, I just wanted to add openssl to an existing installation.
(4) cd extracted dir/ext/openssl
(5) ruby extconf.rb
(6) make
(7) sudo make install

Onwards/Upwards
I re-ran sudo passenger-install-apache-2-module, which completed successfully. As instructed, I pasted the following into /etc/httpd/conf.d/passenger.conf, because all files in conf.d are loaded by httpd.conf:

LoadModule passenger_module /evri/ruby/lib/ruby/gems/1.8/gems/passenger-2.0.6/ext/apache2/mod_passenger.so PassengerRoot /evri/ruby/lib/ruby/gems/1.8/gems/passenger-2.0.6 PassengerRuby /evri/ruby/bin/ruby
I then put in the server directives to map my public directory as well as a specified VirtualHost to my app.


Options FollowSymLinks
AllowOverride none
Order allow,deny
Allow from all



ServerAdmin webmaster@localhost
ServerName xen-5
ServerAlias xen-5.local xen-5.evri.corp
DocumentRoot /var/www/rails/dashboard/current/public
ErrorLog /var/www/rails/dashboard/current/log/server.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel debug



Phusion Passenger aka mod_rails was configured.

Next: Database Migration

2 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete