Passengerを入れてみる[失敗編]
Passenngerが簡単とよく聞くので本当かどうかチェックしてみる。チェックした対象は以下の通り
- Ruby1.8.6 P114
- Rails1.2.6
- Rails2.0.2
- Apache2.0.63
例によってVMWare上にUbuntu8.0.4の環境を作っただけなので、不足分を入れて行く
まずはApache
#wget http://www.meisei-u.ac.jp/mirror/apache/httpd/httpd-2.0.63.tar.gz #tar zxvf httpd-2.0.63.tar.gz -C ../ #cd ../httpd-2.0.63/ #./configure --enable-proxy --enable-headers --enable-rewrite --enable-so #make #maek install
httpd.confでServerNameとAllowOverride等を修正してとりあえずOK
つぎはPassengerを入れるためにgemを入れる(Rubyは導入済み)
#wget http://rubyforge.org/frs/download.php/35283/rubygems-1.1.1.tgz #tar zxvf rubygems-1.1.1.tgz -C ../ #cd ../rubygems-1.1.1/ #ruby ./setup.rb
いよいよPassengerを入れる(Rubyは入ってる)
#gem install passenger #passenger-install-apache2-module
ぬ、いくつかエラーが出たな。
* GNU C++ compiler... not found * Ruby development headers... found * OpenSSL support for Ruby... found * RubyGems... found * Rake... found at /usr/local/bin/rake * Apache 2... not found * Apache 2 development headers... not found * Apache Portable Runtime (APR) development headers... found * fastthread... found
GNU C++コンパイラーがないのか。あとはApache2の環境がみえないのね。
apt-getでコンパイラー系を入れる。
#apt-get install build-essential
export APXS2=/usr/local/apache2/bin/apxs export PATH=/usr/local/apache2/bin/:$PATH
これでもう1回トライ
#passenger-install-apache2-module
これでさっくり通った
* GNU C++ compiler... found at /usr/bin/g++ * Ruby development headers... found * OpenSSL support for Ruby... found * RubyGems... found * Rake... found at /usr/local/bin/rake * Apache 2... found at /usr/local/apache2/bin/httpd * Apache 2 development headers... found at /usr/local/apache2/bin/apxs * Apache Portable Runtime (APR) development headers... found at /usr/local/apache2/bin/apr-config * fastthread... found
最後にhttpd.confに追記する内容が表示されたので、これをhttpd.confの末端に追加
LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-1.0.4/ext/apache2/mod_passenger.so RailsSpawnServer /usr/local/lib/ruby/gems/1.8/gems/passenger-1.0.4/bin/passenger-spawn-server RailsRuby /usr/local/bin/ruby
ついでに、SQLite3がいりそうだからその辺もいれておく
apt-get install sqlite3 apt-get install libsqlite3-dev gem install sqlite3-ruby
いよいよRailsをトライ
#cd /opt #mkdir rails #cd rails #gem install rails --version='1.2.6' #rails tgg12 #gem install rails #rails tgg20
これでrails1.2.6とrails2.0.2の両方の環境ができた。どうしたらpassenerにここがrailsだと認識させられるのかとおもったら~/publicを認識してるらしいので、よくある例の通りにVirtualHostを作ってみる
まずはRails2.0側
DocumentRoot "/opt/rails/tgg20/public" RailsEnv "production" Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all
そして1.2側
DocumentRoot "/opt/rails/tgg20/public" RailsEnv "production" Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all
それぞれの名前に対応した設定をhosts(Linux側とWindows側)に記述しておく。
で、適当なモデルをつくって試してみたところ、Rails2.0はさっくり動くけど、Rails1.2系がどうやっても動かない。「We're sorry, but something went wrong.」になって、Rails2.0は同じエラーがでてもlog出力するのでわかるけど、Rails1.2系はログになにもでないので手が打てない。
うーん、これはRails2.0以後でないとつかえないということなのかなあ。1.2系はおとなしくfast_cgiでつかうかなあ。
補足
上記の考察は間違い。解決編の日記を別途おこしたので、そちらを参照。結論を書いておくとRails1.2/2.0共に正常に動作する。