Gyoung-Yoon Noh
2005-Mar-05 21:22 UTC
How to provide Rails hosting on Apache/FastCGI enviroment?
Hi, folks.
I am running a small Web Hosting service personally.
I hope to provide rails service on apache/fcgi to my hosting
users. So, I''ve been testing to setup rails application, and
there was no problem. But with Rails version 0.10.0 release,
previous way doesn''t work.
Following is a scenario which worked well before, but now beats me.
1. Eric has his own rails directory and he is developing
''funshop''
in that directory. (/home/eric/rails/funshop)
2. Eric symlinks(ln -s) /home/eric/rails/funshop/public to
/home/eric/public_html/funshop. (public_html is web root)
Now, anyone can access http://eric.hosting.com/funshop.
/home/eric/rails/public/.htaccess:
<snip>
# This works well with rails-0.9.5
AddHandler fastcgi-script .fcgi
RewriteEngine On
RewriteBase /funshop/dispatch.fcgi
RewriteRule ^$ /funshop/manager/index [R]
RewriteRule ^([-_a-zA-Z0-9]+)$ /funshop/$1/ [R]
# other trivial parts are same with rails-0.9.5.
</snip>
<snip>
# This doesn''t work around with rails-0.10.0
# But if I puts alias directive in apache.conf, then will work well.
AddHandler fastcgi-script .fcgi
RewriteEngine On
RewriteBase /tekram/
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi?$1 [QSA,L]
</snip>
<snip>
==> log/apache-error.log <=[Sun Mar 06 04:03:12 2005] [error] [client
61.97.238.147] FastCGI:
comm with (dynamic) server
"/home/eric/public_html/funshop/dispatch.fcgi" aborted: (first read)
idle timeout (30 sec)
[Sun Mar 06 04:03:12 2005] [error] [client 61.97.238.147] FastCGI:
incomplete headers (0 bytes) received from server
"/home/eric/public_html/funshop/dispatch.fcgi"
</snip>
There was nothing special in apache configuration when it
worked around ago. (except ''Override All'' to /home/eric)
Now, I put ''Alias /funshop/ /home/eric/rails/funshop/public/''
directive in apache.conf instead of symlinking it, then
it works well. But in this case, whenever an user wants to
develope or install some rails application, s?he nofity that
to me, and then I must put Alias directive and restart apache.
This is somewhat boring thing.
I tried to modify older verision of .htaccess many times,
but I cannot make it. I don''t want to go back to the old days.
Yeah, I know it would be a very annoying job working around
with .htaccess against many complex cases, in compare of
Routes'' magic. I''ll choose rather putting alias to apache.conf
than going back to old days.
So, my question is:
- Is there proper RewriteRule co-working with Routes?
Sure, it also should handle some path prefix such as
''/funshop/:controller/:action/:id''.
or
- How to find %r{^/home/.*?/rails/(.*?)$}, and aliasing
them($&) to web path(/$1) in one configuration?
I mean something like ''AliasMatch ^/home/[^/]+/rails/(.*)$
/$1''
Unfortunately AliasMatch need first command to be web path.
--
http://nohmad.sub-port.net