Rails FedoraCore4 で動かす(1)
- 組み合わせは段階的にこんな感じでしょうか.
Rubyのインストール
- su してコンソールから以下を打って確認するが,Fedora Core4 にはRubyはやっぱり入ってない.
ruby -v
- とりあえず一つずつ実行
yum install ruby
yum install ruby-devel
yum install rdoc
yum install irb
Installed: ruby.i386 0:1.8.4-3.fc4
Dependency Installed: ruby-libs.i386 0:1.8.4-3.fc4
Complete!
…
RubyGemsのインストール
- http://www.rubyonrails.org/down から rubygems-0.9.2.gz をどっか/tmp とかにDLしてくる
- 解凍してインストール
tar -xvzf rubygems-0.9.2.gz
cd rubygems-0.9.2
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install
- FC5以降なら,yumでいける 2007/12/28 追記
Railsのインストール
-- version 1.2.1 とかできるらしい
gem install rails --include-dependencies
Bulk updating Gem source index for: http://gems.rubyforge.org
Successfully installed rails-1.2.2
Successfully installed rake-0.7.1
Successfully installed activesupport-1.4.1
Successfully installed activerecord-1.15.2
Successfully installed actionpack-1.13.2
Successfully installed actionmailer-1.3.2
Successfully installed actionwebservice-1.2.2
Installing ri documentation for rake-0.7.1...
…
WEBrickサーバ起動
rails test
cd test
ruby script/server
=> Booting WEBrick...
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2007-02-20 21:03:33] INFO WEBrick 1.3.1
[2007-02-20 21:03:33] INFO ruby 1.8.4 (2005-12-24) [i386-linux]
[2007-02-20 21:03:33] INFO WEBrick::HTTPServer#start: pid=26535 port=3000
- http://localhost:3000/ Fedora上ですんなり動いた
Hello表示アプリで動確
- コントローラ Say 作成
ruby script/generate controller Say
- アクション hello 作成(/app/controllers/say_controller.rb)
class SayController < ApplicationController def hello end end
- ビュー 作成
<html> <head> <title>Rails!</title> </head> <body> <h1> Helloooooo!! </h1> </body> </html>
- http://localhost:3000/say/hello Fedora上ですんなり動いた
- コントローラ/アクション は認識されている
Apache で生CGIとしてまず動かす
rake tmp:clear
AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI
RewriteEngine On
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
SetEnv RAILS_ENV development
ServerName XX.XX.XX.XX
DocumentRoot /home/xxx/public_html/rails/test/public/
ErrorLog /home/xxx/public_html/rails/test/log/server.log
Options ExecCGI FollowSymLinks
AllowOverride all
Allow from all
Order allow,deny
- Apacheリスタートで http://XX.XX.XX.XX/ には外部からのアクセス成功したが…,http://XX.XX.XX.XX/say/hello にアクセスできない.
- log/server.log をみると,dispatch.cgiで実行でFailがでている.
- log/development.log をみると,/tmp/sessions で Permission deniedになっている.Apacheの書き込みだった.(←結構はまった)
chmode 777 sessions
- で動いたけど…う〜ん.とりあえずはこのまま.
- http://XX.XX.XX.XX/say/hello で Rails が Apache + 生CGI で動いた.うわさ通り,ローカルで使うにしてもこれは遅すぎる.
- development環境からproduction環境にしてみるけど相変わらず遅い
- 次はFastCGIかな.