Setup an old Rails 2.3.8 application on Ubuntu 12.04

In an effort to revive an old Rails application that was built on a 2.3.8 platform we recently set it up and we have it running in the latest Ubuntu 12.0.4 LTS environment. With the thought that this may benefit others who are attempting to do the same we decided to share the steps and tweaks that we underwent.

The stack that we built in the steps below is strictly to revive an old Rails applications. This stack is deprecated and contains some security holes. For new application development projects we recommend that you use Rails 4 with Ruby 2.0.0. You can download and follow steps to install Rails 4 from the following link:

After it was all said and done, the stack that we built looks like this:

  • Ruby-1.8.7-p374
  • Gem 1.3.7
  • Rails 2.3.8
  • MySQL 5.5.32

A Rails 2.3.8 setup is best supported by Ruby 1.8.7. In order to be able install an older version of Ruby and to be able to toggle between different versions, the first step is to install RVM. RVM is a command-line tool which allows you to easily install, manage, and work with multiple Ruby environments from interpreters to sets of Gems. For details on RVM visit:

However, before you install RVM make use that you remove the ruby-rvm installation that comes by default with Ubuntu. This ruby-rvm version is broken and generates a lot of errors. The only safe way is to remove ruby-rvm first:

sudo apt-get --purge remove ruby-rvm
sudo rm -rf /usr/share/ruby-rvm /etc/rvmrc /etc/profile.d/

Now open a new terminal and validate that environment is clean from old RVM settings. There should be no output when you run the following command:

env | grep rvm

If there is an output, try to open new terminal, if it does not help then restart your computer.

Before we start make sure you have curl installed. If not please install curl using:

sudo apt-get install curl

For a multi-user RVM installation on a typical Ubuntu box you will need to execute the following command:

\curl -L | sudo bash -s stable

The multi-user install instructions must be prefixed with the ‘sudo’ command. However, once the install is complete, and the instructions to add users to the ‘rvm’ group are followed, the use of either ‘sudo’ or ‘rvmsudo’ is no longer required.

You can add the user to the ‘rvm’ group by using the ‘usermod’ command. However, you will need to be careful when using the ‘usermod’ command. If it is not used with ‘-a’ option you will modify the user to only belong to the ‘rvm’ group. To avoid this capture the groups that user currently belongs to in case you need to add them later:

id > id.text

Then add the user to the ‘rvm’ group using the following command:

sudo usermod -a -G rvm [user]

Typing ‘id’ should show you the new group added. If you only see the group ‘rvm’, then extract all groups from the ‘id.txt’ file that you created earlier and add them again manually by using the following command:

sudo usermod -G [group1], [group2], rvm [user]

To start using RVM you will need to run the source file in all your open shell windows:

source /etc/profile.d/

You are now ready to install Ruby using RVM. To install a specific version of Ruby type in command:

rvm install 1.8.7

Using this command you can install multiple versions of Ruby on the same Ubuntu box.

To use a specific version of Ruby type in the following:

rvm use 1.8.7

Once the Ruby version is successfully installed and selected to be used you are ready to set up the rails environment and supporting gems by using the following command:

gem install rails -v 2.3.8 --include-dependencies

Additional gems that you will need to manually install using the ‘gem install’ command are listed below.

Before you do that you will need to run the following command:

sudo gem sources -a

  • hpricot
  • httpclient
  • rubyist-aasm
  • capistrano
  • passenger

Before Installing the gem for mysql you will need to install the following libraries:

sudo apt-get install libmysql-ruby
sudo apt-get install libmysqlclient-dev

Once you have installed the above libraries mysql gem can be installed without error:

gem install mysql

At this stage you would have the necessary list of gems installed. You can check the list and version of gems installed on you system by executing the following command:

gem list

In our environment it gives the following ouput:

    actionmailer (2.3.8)
    actionpack (2.3.8)
    activerecord (2.3.8)
    activeresource (2.3.8)
    activesupport (2.3.8)
    bundler (1.3.5)
    bundler-unload (1.0.1)
    capistrano (2.15.5)
    daemon_controller (1.1.5)
    highline (1.6.19)
    hpricot (0.8.6)
    httpclient (
    json (1.8.0)
    mysql (2.9.1)
    net-scp (1.1.2)
    net-sftp (2.1.2)
    net-ssh (2.6.8)
    net-ssh-gateway (1.2.0)
    passenger (4.0.14)
    rack (1.1.6)
    rails (2.3.8)
    rake (10.1.0)
    rdoc (4.0.1)
    rubygems-bundler (1.2.2)
    rubygems-update (1.3.7)
    rubyist-aasm (2.1.1)
    rvm (

You are now ready to install and configure the MySQL server. This is easily done through the Ubuntu Software Center or you can run the following command:

sudo apt-get install mysql-server

Walking through the steps to configure MySQL is fairly straight forward. For more details refer to the following link:

Once MYSQL is installed, you can clone your project from any version control repository. We use Github as a repository for all our projects. If you use Github you can clone a local copy of the project easily using the following ‘git’ command:

sudo apt-get install git
git clone[your_project_address]

Once you have cloned your project, you will need to make a few configurations changes. We are running our project in a ‘development’ environment. We therefore updated the configurations in the ‘development’ section of the ‘database.yml’ file. We still like to use ‘vi’, but you can make edits to the file using any text editor:

vi /[project_directory]/config/database.yml

Once you have made the edits the ‘development’ section of the ‘database.yml’ file, it would look like this:

    adapter: mysql
    encoding: utf8
    database: [rails_project_database_name]
    username: [mysql_user]
    password: [mysql_user_pw]
    socket: [mysql_socket_connection_location]


  • [rails_project_database_name] is the name of the database you will create for your project
  • [mysql_user] is the MySQLuser you created when you installed the MySQL server
  • [mysql_user_pw] is the password for the MySQL user you created when you installed the MySQL server
  • [mysql_socket_connection_location] is the socket location that MySQL database will use when connecting with your rails project

The ‘socket’ connection location is normally defined in the ‘[client]’ section of ‘my.cnf’ file. To view this information you can use ‘cat’ or ‘less’ or simply open the file through text editor:

cat /etc/mysql/my.cnf

You should see the ‘[client]’ section look something like this:

    port = 3306
    socket = /var/run/mysqld/mysqld.sock

If you don’t see these lines defining the ‘socket’ connection location, you can add them in the ‘my.cnf’ file. Be sure to back up the file before you make any changes.

The next step is to create a database that your rails project can use to store the table structure. To log into MySQL and create the database, use the following steps:

mysql –u [mysql_user] –p [mysql_password]
create database [rails_project_database_name];
show databases;

You should see the following output after running the ‘show’ command:

    | Database |
    | information_schema |
    | [rails_project_database_name]|
    | mysql |
    | performance_schema |
    | test |

You are now ready to load the database schema by typing the below ‘rake’ command:

rake --trace db:schema:load RAILS_ENV=development

However, when you run the command you will get the following error:

    rake aborted!
    ERROR: ‘rake/rdoctask’ is obsolete and no longer supported. Use ‘rdoc/task’…

The reason for this is that the version of ‘Rake’ is not comparable with the version of Rails that you have installed.
The version of rails installed is:

  • rake, version 10.1.0

You can solve this error by editing the ‘Rakefile’ in your project directory:

vi /[project_directory]/Rakefile

Edit the file from:

    require ‘rake’
    require ‘rake/testtask’
    require ‘rake/rdoctask’
    require ‘tasks/rails’

Edit the file to:

    require ‘rake’
    require ‘rake/testtask’
    require ‘rdoc/task’
    require ‘tasks/rails’

If you don’t want to edit the ‘Rakefile’, you can switch back to older version of ‘Rake’ take like this:

gem uninstall rake -v 10.1.0
gem install rake -v 0.8.7

For more details refer to this Stack Overflow post.

The next error you will encounter when you try to run ‘db:schema:load’ is:

    rake aborted!
    undefined method `name’ for “actionmailer”:String

The solution is to downgrade Rubygems version to 1.3.7 that is supported by Rails 2.3.8 by running the following commands:

gem install rubygems-update -v 1.3.7
update_rubygems --version=1.3.7

For more details refer to this Stack Overflow post.

With this solution in place you should be able to successfully run:

rake --trace db:schema:load RAILS_ENV=development

You should now be able to see your application database schema loaded by running the following ‘sql’ commands:

use [rails_project_database_name];
show tables;

In the project folder you can now start your application by running the following command:


This will give you following output:

    => Booting WEBrick
    => Rails 2.3.8 application starting on
    => Call with -d to detach
    => Ctrl-C to shutdown server
    [2013-09-07 22:44:16] INFO WEBrick 1.3.1
    [2013-09-07 22:44:16] INFO ruby 1.8.7 (2013-06-27) [x86_64-linux]
    [2013-09-07 22:44:21] INFO WEBrick::HTTPServer#start: pid=3924 port=3000
    You should now be able to access your application in a web browser by typing the following URL:

Congratulations, you have now successfully setup an old Rails 2.3.8 application on Ubuntu 12.04. The next step now would be to convert this into a Rails 4 application. We will share this in an upcoming post.

Leave a Reply