I have a subject about handling environmental variables on FastCGI.
My solution is to modify Rails to suit FastCGI as same as CGI.
Rails has the specification to be controlled with environmental
variables,
but on FastCGI, there is incompatibility about env. variables set by
system (via FastCGI protocol).
I found that applications that have same spec. merge FastCGI env.
variables and process's by themselves.
Rails is not an user application but a middleware, so Rails should
behave like that, I think.
Then, my current way to avoid this problem is overriding
FCGI::RecordBuffer#env to import ENV in dispatch.fcgi.
What particular problem have you hit that would require these changes?
In the case of path based multiple projects on lighttpd + fastcgi.
That needs additional configuration compared with apache, to modify
AbstractRequest.relative_url_root.
Someone set it at config/route.rb.
Someone override AbstractRequest#relative_url_root to refer ENV
originally referring @env built from CGI#env_table.
Of course I should investigate to choose other platform, apache,
mongrel or something else.
But to install them on the user's host, I need the reasonable reason
to persuade.
So I need the current conclusion about using lighttpd.
(I'm sorry but I could not find it on the log.)
In the case of path based multiple projects on lighttpd + fastcgi.
That needs additional configuration compared with apache, to modify
AbstractRequest.relative_url_root.
Someone set it at config/route.rb.
Someone override AbstractRequest#relative_url_root to refer ENV
originally referring @env built from CGI#env_table.
So you'd modify the relative URL root while your application is
running? Or is this only used at startup?
Apache proxies to lighttpd which calls rails through fcgi.
In config/environment.rb I have to include the following:
RAILS_APPLICATION_PREFIX = 'app1'
# uncomment the next line if this application is served from a directory with other rails applications
ActionController::AbstractRequest.relative_url_root = '/' + RAILS_APPLICATION_PREFIX
Part of my lighttpd config for app1 looks like this:
I had thought setting the ENV constant RAILS_RELATIVE_URL_ROOT would serve to set ActionController::AbstractRequest.relative_url_root -- but that didn't work.
I had thought setting the ENV constant RAILS_RELATIVE_URL_ROOT would serve to set ActionController::AbstractRequest.relative_url_root -- but that didn't work.
This is I said.
On FastCGI process's env. and each request's env. are different.
To merge them is responsibility of the application which wants to
refer them equivalently.
And a way to merge them on rails is overriding FCGI::RecordBuffer#env.
#I can't say that this is a FastCGI's protocol bug because I am just a
new comer to world of CGI.
RAILS_APPLICATION_PREFIX = 'app1'
# uncomment the next line if this application is served from a directory with other rails applications
ActionController::AbstractRequest.relative_url_root = '/' + RAILS_APPLICATION_PREFIX
Oops, I've never met these lines.
Is this a recent grammer of rails?
When I deploy multiple rails apps served from subdirectories I set my own constant named: RAILS_APPLICATION_PREFIX in config/environment.rb for later use. I set this constant equal to the name of the directory where the rails app is located.
One use is for setting ActionController::AbstractRequest.relative_url_root.