# One more try - ENV and FastCGI

**URL:** <https://www.ruby-forum.com/t/one-more-try-env-and-fastcgi/59028>\
**Category:** Rails\
**Created:** [April 28, 2006, 12:43am UTC](https://www.ruby-forum.com/t/one-more-try-env-and-fastcgi/59028 "2006-04-28T00:43:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sfmcfar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@sfmcfar](https://www.ruby-forum.com/u/sfmcfar)\
**Post date:** [April 28, 2006, 12:43am UTC](https://www.ruby-forum.com/t/one-more-try-env-and-fastcgi/59028/1 "2006-04-28T00:43:12Z")

</div>

Hi,

I’m desperate, so I thought I’d try one more time in the hopes of  
getting a  
different audience. Basically. it boils down to this. Using CGI, the  
ENV  
hash is populated and is accessible from a model script. Using FastCGI,  
the  
ENV hash is empty. Can anyone explain how I can fix this?

Thanks,

## Stan Mcfarland

View this message in context:  
[http://www.nabble.com/one-more-try---ENV-and-FastCGI-t1521255.html#a4131042](http://www.nabble.com/one-more-try---ENV-and-FastCGI-t1521255.html#a4131042)  
Sent from the RubyOnRails Users forum at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![sfmcfar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@sfmcfar](https://www.ruby-forum.com/u/sfmcfar)\
**Post date:** [April 28, 2006, 2:35am UTC](https://www.ruby-forum.com/t/one-more-try-env-and-fastcgi/59028/2 "2006-04-28T02:35:32Z")

</div>

On Apr 27, 2006, at 3:39 PM, sfmcfar wrote:

> I’m desperate, so I thought I’d try one more time in the hopes of  
> getting a  
> different audience. Basically. it boils down to this. Using CGI,  
> the ENV  
> hash is populated and is accessible from a model script. Using  
> FastCGI, the  
> ENV hash is empty. Can anyone explain how I can fix this?

Perhaps there’s no ENV when FastCGI is started?

I haven’t done any ENV based configuration in Rails, though I used to  
be a  
big fan in mod\_perl days. If you’re using Apache, then you  
specifically need  
to declare which environment vars to pass via the PassEnv  
configuration option.

–  
– Tom M.

---

<div class="post-metadata">

**Author:** ![sfmcfar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@sfmcfar](https://www.ruby-forum.com/u/sfmcfar)\
**Post date:** [April 28, 2006, 4:15am UTC](https://www.ruby-forum.com/t/one-more-try-env-and-fastcgi/59028/3 "2006-04-28T04:15:24Z")

</div>

Well,

FastCGI has a parameter called -initial-env which is suypposed to allow  
you  
set the environmental variables of interest, but I can’t seem to make it  
work. I might need to revisit, though. Thanks for the reminder.

## -stan

View this message in context:  
[http://www.nabble.com/one-more-try---ENV-and-FastCGI-t1521255.html#a4133210](http://www.nabble.com/one-more-try---ENV-and-FastCGI-t1521255.html#a4133210)  
Sent from the RubyOnRails Users forum at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![sfmcfar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@sfmcfar](https://www.ruby-forum.com/u/sfmcfar)\
**Post date:** [April 28, 2006, 2:20pm UTC](https://www.ruby-forum.com/t/one-more-try-env-and-fastcgi/59028/4 "2006-04-28T14:20:31Z")

</div>

sfmcfar wrote:

> Well,
> 
> FastCGI has a parameter called -initial-env which is suypposed to allow  
> you  
> set the environmental variables of interest, but I can’t seem to make it  
> work. I might need to revisit, though. Thanks for the reminder.
> 
> ## -stan
> 
> View this message in context:  
> [http://www.nabble.com/one-more-try---ENV-and-FastCGI-t1521255.html#a4133210](http://www.nabble.com/one-more-try---ENV-and-FastCGI-t1521255.html#a4133210)  
> Sent from the RubyOnRails Users forum at [Nabble.com](http://Nabble.com).

Here’s an entry from a running apache config file setting up my fastcgi  
(if it helps?)

FastCgiServer “C:/WebApps/\_premier/public/dispatch.fcgi” -idle-timeout  
120 -processes 2   
-initial-env  
PATH=“C:/PROGR~1/ruby/bin;C:/PROGR~1/MYSQL/MySQLS~1.0/bin;c:/windows/system32;c:/windows;”  
  
-initial-env RUBYOPT=rubygems   
-initial-env RAILS\_ENV=development

---

<div class="post-metadata">

**Author:** ![sfmcfar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@sfmcfar](https://www.ruby-forum.com/u/sfmcfar)\
**Post date:** [April 28, 2006, 4:36pm UTC](https://www.ruby-forum.com/t/one-more-try-env-and-fastcgi/59028/5 "2006-04-28T16:36:08Z")

</div>

And the ENV hash contains the variables you’ve set with initial-env? I  
can  
get at these variables through  
the request.env object, but I need to access them in a model script, and  
the  
request object isn’t available  
to the model.

Thanks,

-stan

–  
View this message in context:  
[http://www.nabble.com/one-more-try---ENV-and-FastCGI-t1521255.html#a4141212](http://www.nabble.com/one-more-try---ENV-and-FastCGI-t1521255.html#a4141212)  
Sent from the RubyOnRails Users forum at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![sfmcfar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@sfmcfar](https://www.ruby-forum.com/u/sfmcfar)\
**Post date:** [April 28, 2006, 4:26pm UTC](https://www.ruby-forum.com/t/one-more-try-env-and-fastcgi/59028/6 "2006-04-28T16:26:49Z")

</div>

And the ENV hash contains the variables you’ve set with initial-env? I  
can  
get at these variables through  
the request.env object, but I need to access them in a model script, and  
the  
request object isn’t available  
to the model.

Thanks,

-stan

–  
View this message in context:  
[http://www.nabble.com/one-more-try---ENV-and-FastCGI-t1521255.html#a4141220](http://www.nabble.com/one-more-try---ENV-and-FastCGI-t1521255.html#a4141220)  
Sent from the RubyOnRails Users forum at [Nabble.com](http://Nabble.com).
