CentOS 5.5 Ruby on Rails 環境構築

 Red Hat系Linuxのパッケージ管理システムyumからインストールされたRubyはバージョンが古くRailsがインストール出来ないためソースからビルドしインストールした。
 しかし、ソースからビルドし直接インストールした場合、削除・アップデートが非常に困難なためソースから管理を行い易いrpmパッケージを作成しインストールする。

rpmパッケージを作成するためのコマンドcheckinstallのインストール
# rpm -ivh http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/checkinstall-1.6.0-3.el5.rf.i386.rpm

Rubyをソースからrpmパッケージを作成しインストールする

rubyのソースファイルをダウンロード
# wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p302.tar.bz2

展開
# bzip2 -dc | tar xvf ruby-1.8.7-p302.tar.bz2

展開されたruby-1.8.7-p302ディレクトリへ移動
# cd ruby-1.8.7-p302

Makefileを作成する
# ./configure –prefix=/usr

ビルドする
# make

rpmパッケージを作成する checkinstallの使い方は下記に記載
# checkinstall –fstrans=no

checkinstall 1.6.0, Copyright 2002 Felipe Eduardo Sanchez Diaz Duran
This software is released under the GNU GPL.

The package documentation directory ./doc-pak does not exist.
Should I create a default set of package docs? [y]: ← Enter

Preparing package documentation…OK

Please choose the packaging method you want to use.
Slackware [S], RPM [R] or Debian [D]? r ← Enter

Please write a description for the package.
End your description with an empty line or EOF.
>> ← Enter

**************************************
**** RPM package creation selected ***
**************************************

This package will be built according to these values:

1 – Summary: [ Package created with checkinstall 1.6.0 ]
2 – Name: [ ruby-1.8.7 ]
3 – Version: [ p302 ]
4 – Release: [ 1 ]
5 – License: [ GPL ]
6 – Group: [ Applications/System ]
7 – Architecture: [ x86_64 ]
8 – Source location: [ ruby-1.8.7-p302 ]
9 – Alternate source location: [ ]
10 – Requires: [ ]
11 – Provides: [ ruby-1.8.7 ]

Enter a number to change any of them or press ENTER to continue: ← Enter

rpmパッケージが作成されたディレクトリへ移動
# cd /usr/src/redhat/RPMS/x86_64

作成されたrpmパッケージでRubyをインストール
# rpm -ivh ruby-1.8.7-p302-1.x86_64.rpm

Rubyがインストールされたかを確認する
# ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]

Rubyのライブラリを管理するrubygemsをソースからrpmパッケージを作成しインストールする

rubygemsのソースファイルをダウンロード
# wget http://rubyforge.org/frs/download.php/74234/rubygems-1.5.2.tgz

展開
# tar zxvf rubygems-1.5.2.tgz

展開されたrubygems-1.5.2ディレクトリへ移動
# cd rubygems-1.5.2

rpmパッケージを作成する checkinstallの使い方は上記に記載
# checkinstall -R ruby setup.rb

rubygemsからRailsをインストール
# gem install rails –include-dependencies

Railsがインストールされているか確認する
# rails -v
Rails 3.0.7

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(Spamcheck Enabled)

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)