【Platform】Amazon EC2
【OS】Fedora8
【Rails】1.2.3
【Ruby】1.8.7

ディフォルトのRailsのバージョンが2.2.2だったので、
1.2.3にダウングレードする必要があった。

gemを使ってパッケージのバージョン指定してインストールする。


# gem install rails --version '= 1.2.3'

Successfully installed activesupport-1.4.2
Successfully installed activerecord-1.15.3
Successfully installed actionpack-1.13.3
Successfully installed actionmailer-1.3.3
Successfully installed actionwebservice-1.2.3
Successfully installed rails-1.2.3
6 gems installed
Installing ri documentation for activesupport-1.4.2...
Installing ri documentation for activerecord-1.15.3...
Installing ri documentation for actionpack-1.13.3...
Installing ri documentation for actionmailer-1.3.3...
Installing ri documentation for actionwebservice-1.2.3...
Installing RDoc documentation for activesupport-1.4.2...
Installing RDoc documentation for activerecord-1.15.3...
Installing RDoc documentation for actionpack-1.13.3...
Installing RDoc documentation for actionmailer-1.3.3...
Installing RDoc documentation for actionwebservice-1.2.3...
【Platform】Amazon EC2
【OS】Fedora8
【Rails】1.2.3
【Ruby】1.8.7


EC2のディフォルトで用意されているFedora8のAMIからインスタンスを生成。
ここにruby1.8.7をインストールしたのだが、ec2-bundle-volが通らない。
実行すると以下エラーメッセージ。


/usr/lib/site_ruby/ec2/amitools/bundlevol.rb:11:in `require': no such file to load -- ec2/amitools/bundle (LoadError)
from /usr/lib/site_ruby/ec2/amitools/bundlevol.rb:11


ここはウェブの情報によると、ruby1.8.6で実行すると通るらしい。
なので、応急処置として1.8.6のパス(/usr/bin)を先に読み込むように.bash_profileに設定。
PATH=/usr/bin:$PATH


根本的な解決にはなっていないが。。。


【2009/5/1 Edit】
EC2ツールのインストール先が問題だったようだ。
ディフォルトでは
/usr/lib/site_ruby/ec2
に格納されている。
これをruby1.8.7をインストールしたディレクトリである、
/usr/local/lib/ruby/site_ruby
のディレクトリにec2ディレクトリをそのままコピーすると実行できた。
まぁよくよく考えてみればそうだよな。。
【OS】Mac OS X Server (10.5.6)
【Rails】2.2.2
【Ruby】1.8.6


Rails2.2.2をインストール後、NETBEANSで新規プロジェクトを立ちあげる前に、以下のGEMもインストールする必要あり。

activesupport-2.2.2
activerecord-2.2.2
actionpack-2.2.2
actionmailer-2.2.2
activeresource-2.2.2


>sudo gem install --remote activesupport

Successfully installed activesupport-2.2.2
1 gem installed
Installing ri documentation for activesupport-2.2.2...
Installing RDoc documentation for activesupport-2.2.2...

>sudo gem install --remote activerecord

Successfully installed activerecord-2.2.2
1 gem installed
Installing ri documentation for activerecord-2.2.2...
Installing RDoc documentation for activerecord-2.2.2...

>sudo gem install --remote actionpack
Successfully installed actionpack-2.2.2
1 gem installed
Installing ri documentation for actionpack-2.2.2...
Installing RDoc documentation for actionpack-2.2.2...

>sudo gem install --remote actionmailer
Successfully installed actionmailer-2.2.2
1 gem installed
Installing ri documentation for actionmailer-2.2.2...
Installing RDoc documentation for actionmailer-2.2.2...

>sudo gem install --remote activeresource
Successfully installed activeresource-2.2.2
1 gem installed
Installing ri documentation for activeresource-2.2.2...
Installing RDoc documentation for activeresource-2.2.2...

【OS】Mac OS X Server (10.5.6)
【Rails】2.2.2
【Ruby】1.8.6


Mac OS X ServerでRails環境してMySQLを利用する場合、デフォルトだとキャラクターセットがlatin1になっており、rake db:createを実行すると以下のエラーとなり、通らない。※一部*にしてます。


Couldn't create database for {"encoding"=>"utf8", "username"=>"***", "adapter"=>"mysql", "host"=>"***.com", "password"=>"***", "database"=>"***_development", "pool"=>5}, charset: utf8, collation: utf8_general_ci (if you set the charset manually, make sure you have a matching collation)


これはmy.cnfの設定を書き換えてデフォルトキャラクターセットをUTF-8にする必要がある。
my.cnfは環境によってパスを変更。OS X Server10.5.6では/private/etc/my.cnfにある。my.cnfをsudo vimで開いて、以下のオプションを追加する。


[client]
default-character-set = utf8

[mysqld]
default-character-set = utf8
collation-server=utf8_general_ci
character-set-server=utf8

[mysqldump]
default-character-set = utf8

[mysql]
default-character-set = utf8


これで改めてRake db:createを実行すればOK。
実行環境は以下の通り。
【OS】Mac OS X Server (10.5.6)
【Rails】2.2.2
【Ruby】1.8.6

Rails2.2.2はデフォルトのデータベースがSQLite3に変更になっている。これを従来の通りMySQLで運用する際、以下のスクリプトでデータベースを指定する。


>rails -d mysql [アプリケーション名]


mysqlドライバーが取り除かれているので、gemでインストールする必要がある。

>sudo gem install --remote mysql


ただ、Mac OS Xだとここで以下のエラーが発生する。

>sudo gem install --remote mysql

Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install mysql -- --with-mysql-dir=/usr/local/mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
.
.
.
--without-nsllib
--with-mysqlclientlib
--without-mysqlclientlib


Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.7/gem_make.out


これはMac OSのクライアント版であれば、以下のコマンドで解決。

>sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config


OS Xクライアントであれば、ここまでで解決するのだけど、OS Xサーバーだと上記のスクリプトだとうまいいかない。。。それでいろいろ追っていったところ、サーバー版だとどうやらmysqlのクライアントライブラリが付属していないようなのだ。なのでこれをAppleのDarwin Source Codeからダウンロードしてインストールする。

1. MySQL Client Libraryをダウンロード

>wget http://www.opensource.apple.com/darwinsource/other/MySQL-43.binaries.tar.gz

--2009-01-02 02:03:13-- http://www.opensource.apple.com/darwinsource/other/MySQL-43.binaries.tar.gz
Resolving www.opensource.apple.com... 17.254.17.70
Connecting to www.opensource.apple.com|17.254.17.70|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 95694028 (91M) [application/x-tar]
Saving to: `MySQL-43.binaries.tar.gz'
100%[==========>] 95,694,028 260K/s in 6m 2s

2009-01-02 02:09:16 (258 KB/s) - `MySQL-43.binaries.tar.gz' saved [95694028/95694028]

2. MySQL Client Libraryをインストール

>tar -xzvf MySQL-43.binaries.tar.gz

MySQL-43.binaries/
MySQL-43.binaries/MySQL-43.root.tar.gz
MySQL-43.binaries/README

>cd MySQL-43.binaries
>sudo tar -xzvf MySQL-43.root.tar.gz -C /

3. 改めてgemでmysqlドライバーをインストール (OS Xクライアントとmysql_configのPathが異なっているので、それぞれの環境に合わせてパスを変更する)

>sudo gem install --remote mysql -- --with-mysql-config=/usr/bin/mysql_config

Building native extensions. This could take a while...
Successfully installed mysql-2.7
1 gem installed


よし、解決。