# Problem moving from lighty-fastcgi to apache-mongrel

**URL:** <https://www.ruby-forum.com/t/problem-moving-from-lighty-fastcgi-to-apache-mongrel/67325>\
**Category:** Rails\
**Created:** [September 2, 2006, 8:43am UTC](https://www.ruby-forum.com/t/problem-moving-from-lighty-fastcgi-to-apache-mongrel/67325 "2006-09-02T08:43:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeroen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@jeroen](https://www.ruby-forum.com/u/jeroen)\
**Post date:** [September 2, 2006, 8:43am UTC](https://www.ruby-forum.com/t/problem-moving-from-lighty-fastcgi-to-apache-mongrel/67325/1 "2006-09-02T08:43:09Z")

</div>

Hi,

In my environment.rb I want to pick up a variable called ENV[‘site’]  
that should be set by the webserver. Using lighty I could do it, but how  
do you achieve this with Apache, mod\_proxy\_balancer and Mongrel?

Jeroen

---

<div class="post-metadata">

**Author:** ![jeroen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@jeroen](https://www.ruby-forum.com/u/jeroen)\
**Post date:** [September 2, 2006, 9:36am UTC](https://www.ruby-forum.com/t/problem-moving-from-lighty-fastcgi-to-apache-mongrel/67325/2 "2006-09-02T09:36:02Z")

</div>

On Sat, 2006-09-02 at 08:43 +0200, Jeroen wrote:

> Hi,
> 
> In my environment.rb I want to pick up a variable called ENV[‘site’]  
> that should be set by the webserver. Using lighty I could do it, but how  
> do you achieve this with Apache, mod\_proxy\_balancer and Mongrel?

Easiest way is to just set it in a mongrel.conf. Just create a file  
with:

```
ENV['site'] = "www.joesfancywidgets.com"

```

Name it mongrel.conf, and then start your mongrel with:

```
mongrel_rails start -e production -S mongrel.conf

```

The mongrel.conf file is loaded before rails or anything else and it is  
a ruby script.

Try it out and let me know how it works.

–  
Zed A. Shaw

> **[Zed A. shaw](https://zedshaw.com/)**
>
> Personal essays and writings by Zed A. Shaw.

[http://mongrel.rubyforge.org/](http://mongrel.rubyforge.org/)  
[http://www.lingr.com/room/3yXhqKbfPy8](http://www.lingr.com/room/3yXhqKbfPy8) – Come get help.

---

<div class="post-metadata">

**Author:** ![jeroen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@jeroen](https://www.ruby-forum.com/u/jeroen)\
**Post date:** [September 2, 2006, 11:20am UTC](https://www.ruby-forum.com/t/problem-moving-from-lighty-fastcgi-to-apache-mongrel/67325/3 "2006-09-02T11:20:50Z")

</div>

Hi Zed,

Hmm, it doesn’t seem to work, no errors but no cigar either. here’s what  
I do

ror1:/w/tennis/current$ sudo mongrel\_rails start -e production -p 80 -S  
config/mongrel.conf  
\*\* Starting Mongrel listening at 0.0.0.0:80  
\*\* Starting Rails with production environment …  
\*\* Rails loaded.  
\*\* Loading any Rails specific GemPlugins  
\*\* Loading config/mongrel.conf external config script  
\*\* Signals ready. TERM =\> stop. USR2 =\> restart. INT =\> stop (no  
restart).  
\*\* Rails signals registered. HUP =\> reload (without restart). It might  
not work well.  
\*\* Mongrel available at 0.0.0.0:80

The idea is that, depending on which Vhost is getting the request,  
ENV[‘site’] is set to a particular value. With that value the correct  
database, css etc gets loaded.

Jeroen

Zed S. wrote:

> On Sat, 2006-09-02 at 08:43 +0200, Jeroen wrote:
> 
> > Hi,
> > 
> > In my environment.rb I want to pick up a variable called ENV[‘site’]  
> > that should be set by the webserver. Using lighty I could do it, but how  
> > do you achieve this with Apache, mod\_proxy\_balancer and Mongrel?
> 
> Easiest way is to just set it in a mongrel.conf. Just create a file  
> with:
> 
> ENV[‘site’] = “[www.joesfancywidgets.com](http://www.joesfancywidgets.com)”
> 
> Name it mongrel.conf, and then start your mongrel with:
> 
> mongrel\_rails start -e production -S mongrel.conf
> 
> The mongrel.conf file is loaded before rails or anything else and it is  
> a ruby script.
> 
> Try it out and let me know how it works.
> 
> –  
> Zed A. Shaw  
> [http://www.zedshaw.com/](http://www.zedshaw.com/)  
> [http://mongrel.rubyforge.org/](http://mongrel.rubyforge.org/)  
> [http://www.lingr.com/room/3yXhqKbfPy8](http://www.lingr.com/room/3yXhqKbfPy8) – Come get help.

---

<div class="post-metadata">

**Author:** ![jeroen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@jeroen](https://www.ruby-forum.com/u/jeroen)\
**Post date:** [September 2, 2006, 11:46am UTC](https://www.ruby-forum.com/t/problem-moving-from-lighty-fastcgi-to-apache-mongrel/67325/4 "2006-09-02T11:46:53Z")

</div>

Strange, if I do a \<%=debug ENV %\> in my view I _do_ see an entry for  
“SITE” so you’re method works as advertised.

Last line in my environment.rb:  
RAILS\_DEFAULT\_LOGGER.warn(‘SITE:’ + ENV[‘SITE’].inspect)

But this ouputs “SITE: nil” in my production.log

Any ideas?

Jeroen
