Ruby on Rails CentOS5.4へのインストール

line

色々試しましたが、結果、ソースからコンパイルしてインストールする事にしました。

環境及びバージョン
・CentOS: 5.4
・Ruby: 1.8.7-p174
・Gem: 1.3.5
・Rails: 2.3.5
・MySQL: 5.0.77

事前準備

1
2
3
$ yum install gcc* compat-gcc* compat-lib*
$ yum groupinstall 'Development Libraries'
$ yum install git

zlibライブラリの確認

1
2
3
4
$ yum list installed *zlib*
Installed Packages
zlib.i386                1.2.3-3              installed
zlib-devel.i386          1.2.3-3              installed

rubyのインストール

1
2
3
4
5
6
7
8
$ wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p174.tar.gz
$ tar zxvf ruby-1.8.7-p174.tar.gz
$ cd ruby-1.8.7-p174
$ ./configure --prefix=/usr
$ make
$ make install
$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-linux]

iconv-rubyのインストール

1
2
3
4
$ cd ext/iconv/
$ ruby extconf.rb --with-iconv-dir=/usr/local
$ make
$ make install

RubyGemのインストール

1
2
3
4
5
6
$ wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz
$ tar zxfv rubygems-1.3.5.tgz
$ cd rubygems-1.3.5
$ ruby setup.rb
$ gem -v
1.3.5

Railsのインストール

1
2
3
4
$ gem install rails -v=2.2.2
$ gem list rails
*** LOCAL GEMS ***
rails (2.2.2)

MySQLアダプタのインストール

1
$ gem install mysql -- --with-mysql-config=/usr/bin/mysql_config

各アップデート(任意)

1
2
3
$ gem update --system
$ gem update
$ gem cleanup

apacheへPassenger(mod_ruby)の組み込み(1)

1
2
3
4
5
6
7
8
9
10
$ gem install passenger
$ passenger-install-apache2-module
数回[Enter]
...
Please edit your Apache configuration file, and add these lines:
の下に、Passengerモジュールを組み込む為の表示がされる。
...
Suppose you have a Rails application in /somewhere. Add a virtual host to your
Apache configuration file and set its DocumentRoot to /somewhere/public:
の下に、VirtualHostの設定例が表示される。

apacheへPassenger(mod_ruby)の組み込み(2)

1
2
3
4
$ vi /etc/httpd/conf.d/passenger.conf
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.7/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.7
PassengerRuby /usr/bin/ruby

VirtualHost設定のサンプル

1
2
3
4
5
6
7
8
9
$ vi /etc/httpd/conf.d/vir-www.yourhost.com.conf
ServerName www.yourhost.com
DocumentRoot /somewhere/html  # be sure to point to 'public'!
RailsEnv development  #  開発の場合
#RailsBaseURI /  # ルートで稼動させる場合
RailsBaseURI /sub  # サブディレクトリで稼動させる場合
 
AllowOverride all  # relax Apache security settings
Options -MultiViews  # MultiViews must be turned off

設定の反映

1
2
$ /etc/rc.d/init.d/httpd configtest
$ /etc/rc.d/init.d/httpd reload

こんな感じです~、(^_^)/~

(2022/05/01) コメントスパムが多くなりましたので、コメントの投稿を一時無効にしました。
(2022/11/26) Trackbackも一時無効にしました。