Rails + Apache1.3 + FastCGI + OSX(10.3.9 Panther)
木曜日, 11月 8th, 2007gem について
Rails アプリを立ち上げたときに、こんなエラーが出たら
./script/../config/boot.rb:29: undefined method `gem' for main:Object (NoMethodError)
from script/server:2
こうする
gem update --system
参考:
WEBメモ モデルがつくれない
はまり1.
まずgemにパスが通ってないといけない
finkの方を見ないように
export PATH=/usr/local/bin:/sw/bin:$PATH
参考:
pools.jp | OSX Panther (OSX10.3.9) へのRuby on Rails 導入メモ
304 - narucissus is Not Modified: Mac OS X 10.3(Panther)でRuby on Rails その2
railsのインストール
gem install rails --include-dependencies
参考:
cyano: Mac OS XでCapistranoを使う方法
はまり2.
まず WEbrick での動作確認ではまる
cd rails_app/script
ruby server
では駄目
/rails/info/properties' not found.
以下でOK
cd rails_app/
ruby script/server
まずCGIモードで動かすために
アプリをパブリックの外に置くためにシンボリックリンクを貼る
はまり3.
File exsits
と出るときはリンクの貼る向きが逆かも。
参考:
RoR Wiki 翻訳 Wiki - シンボリックリンクを使ってWebサイトにRailsアプリを接ぎ木する方法
.htaccessの書き換え
はまり4.
Alias の設定はいらない
RewriteBase を設定
RewriteBase /~(user_name)/demo
参考:
さくらのレンタルサーバにRuby on Railsをインストールする方法
いよいよFastCGiで動かす
fcgi-2.4.0 の make
tar -zxvf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0/
./configure
make
sudo make install
mod_fastcgi のインストールと http.conf 書き換え
tar -zxvf mod_fastcgi-2.4.2.tar.gz
cd mod_fastcgi-2.4.2
apxs -o mod_fastcgi.so -c *.c
sudo apxs -i -a -n fastcgi mod_fastcgi.so
参考:
yosshi-log » Blog Archive » Mac OSX + Apache 1.33 + FastCGI
Apache1.3+FastCGIのインストール (MacOSX編) | hippos-lab::blog
はまり5.
User_dir で動かしたいのでマックだと
/private/etc/httpd/users/(user_name).conf
を編集すること
<ifmodule mod_fastcgi.c> FastCgiIpcDir /tmp/fcgi_ipc/ # FastCgiServer /Users/(user_name)/rails_1.2.5/demo/public/dispatch.fcgi # -initial-env RAILS_ENV=development # -processes 15 -idle-timeout 60 </ifmodule> <directory "/Users/(user_name)/Sites/"> Options Indexes MultiViews FollowSymLinks AllowOverride All Order allow,deny Allow from all </directory>
参考:
Typo のインストール : blog.imladris.jp
はまり6.
tmp と log ディレクトリのパーミッションを Apache から書き込み可能にすること
参考:
pylori*style wiki - RailsでWikiクローンを作る12
はまり7.
demo アプリを作ったときにfcgiに切り替えると
no route
のエラーがでるときは
.htaccess の RewriteRule を書く順番が間違っている。
コメントアウトされているところではなくファイルの末尾に
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
を書くこと
Rails は FastCGI じゃないと遅くて使えないかも。
でもサーバの設定が面倒だ。
ああ今日もたくさんはまったなあ。