[ruby-list:44044] ApacheでVirtual hostを使わない設定でRailsを動かしたい
From:
"paptimusx scirocco" <paptimusx@...>
Date:
2007-09-20 09:57:45 UTC
List:
ruby-list #44044
ApacheでVirtual hostを使わない設定でRailsを動かしたいのですが、
なかなかうまくいきません。
単独のテーブルにScaffoldしただけのRailsを試しに載せようとして
四苦八苦しています。
まだFastCGIでもなくCGIの段階です。
我ながら情けない質問で申し訳ないのですが、どなたか助けてください。
=================================== script/server = OUTPUT
(http://localhost:3000/note/list)
Listing pages
Name Title Freezeflag Updated at Content
New page
=================================== apache ======= OUTPUT
(http://localhost/test3/note/list)
This line is a part of content body.
ruby.cgi=これは普通のCGIから出力してみた
つまりRailsではない。
⇒ .htaccessの設定はうまくいったということだ
C:/USER/Export/http/Rails/test3/public/../config/environment.rb
1-RAILS_ROOT=C:/USER/Export/http/Rails/test3/public/../config/..
2-RAILS_ROOT=C:/USER/Export/http/Rails/test3/public/../config/..
ADDITIONAL_LOAD_PATHSはあるか? 無いようだ。
pre-Dispatcher.dispatch
Dispatcher.dispatch で routing error になる
Content-Type: text/html; charset=UTF-8 Set-Cookie:
_test3_session_id=9eeed32e00aff9595e3ad9035d0fd944; path=/ Status: 500
Internal Error Cache-Control: no-cache Content-Length: 17002
RuntimeError in NoteController#list
unknown error
RAILS_ROOT: C:/USER/Export/http/Rails/test3/public/../config/..
Application Trace | Framework Trace | Full Trace
C:/ruby/lib/ruby/1.8/dl/import.rb:29:in `initialize'
C:/ruby/lib/ruby/1.8/dl/import.rb:29:in `dlopen'
:
==================================================
test3/public/ruby.cgi (dispatch.cgiの代わり/調査用)
#!c:/ruby/bin/ruby -Ks
require 'cgi.rb'
cgi = CGI.new("html4")
# html = cgi.html { cgi.body { cgi.p { cgi.a("foo") { "foo" } } } }
print cgi.header
# Content-Type: text/html
# print cgi.prety("abcdefg")
cgi.print "This line is a part of content body.\r\n"
cgi.print "<p>ruby.cgi=これは普通のCGIから出力してみた<br>つまりRailsではない。<br>";
cgi.print "⇒ .htaccessの設定はうまくいったということだ<br>\n";
cgi.print File.dirname(__FILE__) + "/../config/environment.rb" unless
defined?(RAILS_ROOT)
require File.dirname(__FILE__) + "/../config/environment" unless
defined?(RAILS_ROOT)
cgi.print "<br>1-RAILS_ROOT=#{RAILS_ROOT}<br>\n";
require "dispatcher"
cgi.print "<br>2-RAILS_ROOT=#{RAILS_ROOT}<br>\n";
cgi.print "<hr>\n";
cgi.print "ADDITIONAL_LOAD_PATHSはあるか? 無いようだ。<br>\n"
ADDITIONAL_LOAD_PATHS.reverse.each { |dir|
cgi.print "dir=#{dir}<br>"
$:.unshift(dir) if File.directory?(dir)
} if defined?(Apache::RubyRun)
# config/environment.rbあたりで設定すればよい? ... require dispatcher のあとでないと?
ActionController::AbstractRequest.relative_url_root = '/test3'
cgi.print "<p>pre-Dispatcher.dispatch<br>";
cgi.print "<hr>";
cgi.print "Dispatcher.dispatch で routing error になる<br>";
cgi.print "<hr>";
Dispatcher.dispatch
cgi.print "<hr>";
cgi.print "<p>aft-Dispatcher.dispatch<br>";
__END__
require File.dirname(__FILE__) + "/../config/environment" unless
defined?(RAILS_ROOT)
If you're using RubyGems and mod_ruby, this require should be changed
to an absolute path one, like:
"/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" --
otherwise performance is severely impaired
require "dispatcher"
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if
File.directory?(dir) } if defined?(Apache::RubyRun)
Dispatcher.dispatch
================================================== httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule fastcgi_module modules/mod_fastcgi-2.4.2-ap20.dll
:
ScriptAlias /test3 "c:/USER/Export/http/Rails/test3/public"
<Directory "c:/USER/Export/http/Rails/test3/public">
# AddHandler fastcgi-script .fcgi
Options +ExecCGI
AllowOverride all
Allow from all
Order allow,deny
</Directory>
#FastCgiServer C:/USER/Export/http/Rails/test3/public/dispatch.fcgi -processes 1
================================================== public/.haccess
# General Apache options
AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI
RewriteEngine On
#RewriteRule ^(.*)$ /test3/dispatch.fcgi [QSA,L]
#RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
RewriteRule ^(.*)$ ruby.cgi [QSA,L]
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /test3/dispatch.cgi [QSA,L]
#RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
#RewriteRule ^(.*)$ /test3/dispatch.cgi [QSA,L]
#RewriteRule ^(.*)$ /test3/dispatch.fcgi [QSA,L]
#ErrorDocument 500 "<h2>Application error</h2>Rails application failed
to start properly"