User Tools

Site Tools




apt-get install ruby irb ruby1.8 irb1.8 libreadline-ruby1.8 libruby1.8
apt-get install ruby1.8-examples rdoc ri rdoc1.8 ri1.8
apt-get install ruby1.8-dev
apt-get install liberuby
apt-get install libapache2-mod-ruby libapache-ruby1.8
apt-get install ruby libopenssl-ruby libopenssl-ruby1.8
apt-get install sqlite3 sqlite3-doc libsqlite3-dev libsqlite3-ruby libsqlite3-ruby1.8 libsqlite3-0


I've made 2 modifications to the RubyGems source, so I can keep all gem-related files within /usr/local: allowing specification of the bin directory, and having gems go in the sitelib directory instead of the libdir directory (which is in /usr).

tar xfz rubygems-$VERSION.tgz
cd rubygems-$VERSION
patch -p0 <<EOF
--- lib/rubygems.rb.ORIGINAL    2009-07-21 18:46:08.000000000 -0500
+++ lib/rubygems.rb     2010-01-26 15:13:48.000000000 -0600
@@ -398,9 +398,7 @@
   # The path where gem executables are to be installed.
   def self.bindir(install_dir=Gem.dir)
-    return File.join(install_dir, 'bin') unless
-      install_dir.to_s == Gem.default_dir
-    Gem.default_bindir
+    Gem.configuration['bindir'] || Gem.default_bindir || File.join(install_dir, 'bin')
--- lib/rubygems/defaults.rb.ORIGINAL   2009-06-22 17:54:36.000000000 -0500
+++ lib/rubygems/defaults.rb    2010-01-26 14:48:11.000000000 -0600
@@ -20,13 +20,8 @@
     if defined? RUBY_FRAMEWORK_VERSION then
       File.join File.dirname(ConfigMap[:sitedir]), 'Gems',
-    # 1.9.2dev reverted to 1.8 style path
-    elsif RUBY_VERSION > '1.9' and RUBY_VERSION < '1.9.2' then
-      File.join(ConfigMap[:libdir], ConfigMap[:ruby_install_name], 'gems',
-                ConfigMap[:ruby_version])
-      File.join(ConfigMap[:libdir], ruby_engine, 'gems',
-                ConfigMap[:ruby_version])
+      File.join(ConfigMap[:sitelibdir], 'gems')
--- lib/rubygems/commands/setup_command.rb.ORIGINAL     2009-06-25 19:43:45.000000000 -0500
+++ lib/rubygems/commands/setup_command.rb      2010-01-26 14:46:35.000000000 -0600
@@ -28,6 +28,11 @@
       options[:destdir] = File.expand_path destdir
+    add_option '--bindir=BINDIR',
+               'Directory to install RubyGems binaries into' do |value, options|
+      options[:bindir] = File.expand_path value
+    end
     add_option '--[no-]vendor',
                'Install into vendorlibdir not sitelibdir',
                '(Requires Ruby 1.8.7)' do |vendor, options|
@@ -91,6 +96,7 @@
     @verbose = Gem.configuration.really_verbose
     install_destdir = options[:destdir]
+    install_bindir = options[:bindir]
     unless install_destdir.empty? then
       ENV['GEM_HOME'] ||= File.join(install_destdir,
@@ -109,9 +115,9 @@
     install_lib lib_dir
-    install_executables bin_dir
+    install_executables install_bindir
-    remove_old_bin_files bin_dir
+    remove_old_bin_files install_bindir
     remove_source_caches install_destdir
sudo ruby setup.rb --no-format-executable --bindir=/usr/local/bin --no-vendor --no-rdoc --no-ri
cd ..
rm rubygems-$VERSION.tgz
rm -rf rubygems-$VERSION


We can configure RubyGems to use different directories than the default, by using an /etc/gemrc file. We can also use it to prevent generation of RDoc and RI documentation.

sudo sh -c 'cat > /etc/gemrc' <<END
# Don't generate RDoc or RI documentation when installing gems.
gem: --no-rdoc --no-ri
# Install any binaries into /usr/local/bin, instead of /usr/bin/.
bindir: /usr/local/bin/
# Gems should be installed in the site-local Ruby directory.
  - /usr/local/lib/site_ruby/1.8/gems/


sudo gem install rake
sudo gem install rack
sudo gem install bundler
sudo gem install mongrel
sudo gem install mongrel_cluster
sudo gem install sqlite3-ruby
sudo gem install rails
sudo gem install capistrano capistrano-ext
sudo gem install haml
sudo gem install hpricot
sudo gem install nokogiri
sudo gem install tidy
sudo gem install rspec rspec-rails
sudo gem install cucumber
sudo gem install ZenTest
sudo gem install rcov
sudo gem install heckle
sudo gem install data_mapper dm-core dm-more data_objects do_sqlite3
sudo gem install mocha ;# Required to test ActiveRecord.
sudo gem install technicalpickles-jeweler --s ;# Required by BrowserCMS, to create a GEM spec.
sudo gem install tinder ;# Required by report_card.

Phusion Passenger (mod_rails)

sudo apt-get install apache2-prefork-dev ;# Required to compile the Passenger module for Apache. Has several dependencies.
sudo gem install passenger
sudo passenger-install-apache2-module ;# NOTE: Interactive process.
sudo sh -c 'cat > /etc/apache2/mods-available/passenger.load' <<END
LoadModule passenger_module /usr/local/lib/site_ruby/1.8/gems/gems/passenger-$VERSION/ext/apache2/
sudo sh -c 'cat > /etc/apache2/mods-available/passenger.conf' <<END
<IfModule mod_passenger.c>
    PassengerRuby /usr/bin/ruby
    PassengerRoot /usr/local/lib/site_ruby/1.8/gems/gems/passenger-$VERSION
    PassengerLogLevel 0
sudo a2enmod passenger
sudo /etc/init.d/apache2 force-reload

Upgrading Phusion Passenger

If you do a gem update and Phusion Passenger gets updated, you'll need to build the new version of the Apache module, and configure Apache to use it:

OLD_PASSENGER_ROOT=`passenger-config --root`
sudo gem update
NEW_PASSENGER_ROOT=`passenger-config --root`
sudo passenger-install-apache2-module ;# NOTE: Interactive process; will take a couple minutes to compile.
sudo sed -i -e "s|$OLD_PASSENGER_ROOT|$NEW_PASSENGER_ROOT|g" /etc/apache2/mods-available/passenger.load
sudo sed -i -e "s|$OLD_PASSENGER_ROOT|$NEW_PASSENGER_ROOT|g" /etc/apache2/mods-available/passenger.conf
sudo /etc/init.d/apache2 force-reload

Rake Command Completion

Note that you can directly grab files from, but you need to strip the DOS carriage returns.

sudo sh -c 'curl | tr -d "\r" > /usr/local/bin/rake.completion'
sudo chmod 755 /usr/local/bin/rake.completion
sudo sh -c 'cat > /etc/bash_completion.d/rake' <<EOF
complete -C /usr/local/bin/rake.completion -o default rake
sudo sed -i -e 's/1..-1/0..-1/' /usr/local/bin/rake.completion


IRB config


Extra Gems

sudo gem install map_by_method
sudo gem install what_methods


We chose Integrity as a continuous integration system, as it's simple and easy to use. It's still a bit immature though, so the installation process is a bit rough.

First, we install the gem dependencies:

sudo gem install builder
sudo gem install sinatra sinatra-authorization
sudo gem install sinatra-ditties ;# Also installed mime-types, mailfactory, tlsmail
sudo gem install thor

Then we pull the latest version from GitHub:

CI_PASSWORD=`echo -n "$CI_PASSWORD" | sha1sum | awk '{print $1}'`
git clone git:// $CI_DIR
cd $CI_DIR

Next we set the configuration:

cp config/
cat > config.yml <<END
:base_uri: http://$CI_HOST
:database_uri: sqlite3://$CI_DIR/integrity.db
:export_directory: $CI_DIR/builds
:log: $CI_DIR/log/integrity.log
:use_basic_auth: true
:admin_username: $CI_ADMIN
:admin_password: $CI_PASSWORD
:hash_admin_password: true

Generate a CSS file via SASS:

sass views/integrity.sass > public/integrity.css

Create the SQLite database:

ruby -rubygems bin/integrity migrate_db config.yml

Add support for email notifications:

git clone git:// $CI_DIR/integrity-email
sed -i -e 's|# require "notifier/email"|require "integrity-email/lib/integrity/notifier/email"\nIntegrity::Notifier.register(Integrity::Notifier::Email)|'

Create a few directories required to run:

mkdir -p log
mkdir -p tmp

And finally, tell Passenger to restart the web application. (This assumes you've configured the site already.)

touch tmp/restart.txt

Once you've got the site running, log in as the user you created. Click the link to create the first project. The GIT repository should be something like git://; I'd suggest the following command to use as the build script for Rails applications:

git submodule update --init && rake db:migrate && rake spec && rake cucumber && rake stats

Run the build manually to test to ensure it works as expected. Once it's working manually, configure the GitHub repository post-commit hook. Go to the Github page for the project, and click on the Edit button. (If you don't see it, make sure it's your project, not someone else's.) Then click on the Service Hooks tab and enter the Integrity URL in the Post-Receive URLs section. The Integrity URL should look something like:



Need to configure and test email notifications.

Need to document how to handle SSH keys for private repositories.

build/rails.txt · Last modified: 2012/12/10 22:41 (external edit)