Rails & mongrel & mongrel_cluster

今日は夜9:00過ぎにうちに帰ってきてからRails & mongrel & mongrel_cluster環境を一気につくってみた。環境はCentos5。よしよし。だいぶ自分の中でRailsの環境が飲み込めてきた。
ちなみにgem install の--include-dependenciesオプションはいらなくなったので書いてない。

MySQL関連

yum -y install mysql mysql-devel mysql-server
=================================================
手作業で/etc/my.cnfを編集してUTF-8に統一
=================================================
service mysqld restart
chkconfig mysqld on

mysqladmin -u root password 'xxxxx'

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

Rails関連

gem install rails

RMagick

#RMagickのインストールに必要なフォント
wget htt{長いので省略}msttcorefonts-2.0-1.noarch.rpm 
rpm -ivh msttcorefonts-2.0-1.noarch.rpm
ln -s /usr/share/fonts/msttcorefonts/ /usr/share/fonts/default/TrueType/

# ポストスクリプトエラーが出る場合に必要らしい
yum -y install ghostscript*

# imagemagick関連のインストール
yum -y install ImageMagick ImageMagick-devel

# rmagickのインストール
gem install rmagick

大方そろったところでディプロイ

=================================================
ここでCapistranoか何かでRailsアプリのディプロイ。
でも今日はCapistrano調べるところまで手が回らなかったので
手作業。
DBはMigrationとか使いこなしてないひとは、
開発環境で使ってるMySQLのテーブルコピーとかしても吉。
=================================================

apacheサーバ

yum -y install httpd

apacheサーバの設定ファイル

以下のファイルを/etc/httpd/conf.d/配下にxxx.confと言う名前で保存

ProxyRequests Off

  Order deny,allow
  Allow from all


# 自分のサーバ内でMongrelに分散する設定
# サーバに一つ。BalancerMemberの数はサーバ負荷に応じて調整

  BalancerMember http://127.0.0.1:3000
  BalancerMember http://127.0.0.1:3001
  BalancerMember http://127.0.0.1:3002


  ServerAdmin admin@example.com
  ServerName ホスト名+ドメイン名とか <=うちだとwww.clickyourstyle.com
  ServerAlias ドメイン名とか <=うちだとclickyourstyle.com
  ProxyPass / balancer://mongrelcluster/
  ProxyPassReverse / balancer://mongrelcluster/

その後

chkconfig httpd on
service httpd restart

Mongrel

cd {railsのルート}
gem install daemons gem_plugin mongrel mongrel_cluster
mongrel_rails cluster::configure -e production -p 8000 -N 3
mongrel_rails cluster::start


以上。
RubyRubyGemsのインストールははしょった。

宿題:やったことは可能な限りShellで書き留めておく。


こういうの、新しいバージョンが出る度に最初に使っていく人って偉いね。