# Rails 2.3.2, Apache2 and CGI not working

**URL:** <https://www.ruby-forum.com/t/rails-2-3-2-apache2-and-cgi-not-working/163725>\
**Category:** Deployment\
**Created:** [March 24, 2009, 12:10pm UTC](https://www.ruby-forum.com/t/rails-2-3-2-apache2-and-cgi-not-working/163725 "2009-03-24T12:10:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![futlib](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/7ea924/32.png) [@futlib](https://www.ruby-forum.com/u/futlib)\
**Post date:** [March 24, 2009, 12:10pm UTC](https://www.ruby-forum.com/t/rails-2-3-2-apache2-and-cgi-not-working/163725/1 "2009-03-24T12:10:50Z")

</div>

Hi,

I am trying to deploy a trivial rails application on an apache server,  
using the, as I understand obsolete, CGI way.

First of all, some versions:

System: Debian 5.0  
Apache: Apache 2.2.9  
Ruby: 1.8.7  
Gem: 1.3.1 (manually installed, downloaded from [rubyonrails.org](http://rubyonrails.org))  
Installed gems:  
actionmailer (2.3.2)  
actionpack (2.3.2)  
activerecord (2.3.2)  
activeresource (2.3.2)  
activesupport (2.3.2)  
rails (2.3.2)  
rake (0.8.4)

## Contents of the .htaccess file in my rails app’s public directory: (A cluster of howtos seems to agree that this is what it’s content should be.)

## Options ExecCGI FollowSymLinks AddHandler cgi-script .cgi SetEnv RAILS\_ENV production RewriteEngine on RewriteRule ^$ index.html [QSA] RewriteRule ^([^.]+)$ $1.html [QSA] RewriteCond %{REQUEST\_FILENAME} !-f RewriteRule ^(.\*)$ dispatch.cgi [QSA,L]

This is how I created my rails application (according to:  
[Ruby on Rails 2.3 Release Notes — Ruby on Rails Guides](http://guides.rubyonrails.org/2_3_release_notes.html)):  
rails railstest --with-dispatchers

## My problem is, it won’t work. I get the following error:

## /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action\_controller/cgi\_process.rb:22:in ` __send__': You have a nil object when you didn't expect it! (NoMethodError) The error occurred while evaluating nil.env_table from /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/cgi_process.rb:22:in `dispatch\_cgi’ from /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action\_controller/dispatcher.rb:102:in `dispatch_cgi' from /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/dispatcher.rb:28:in `dispatch’ from ./dispatch.cgi:10

I can’t find anything in particular about that problem, can you help me?

---

<div class="post-metadata">

**Author:** ![futlib](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/7ea924/32.png) [@futlib](https://www.ruby-forum.com/u/futlib)\
**Post date:** [March 25, 2009, 9:42am UTC](https://www.ruby-forum.com/t/rails-2-3-2-apache2-and-cgi-not-working/163725/2 "2009-03-25T09:42:11Z")

</div>

Fut Lib wrote:

> Hi,
> 
> I am trying to deploy a trivial rails application on an apache server,  
> using the, as I understand obsolete, CGI way.

CGI support will be removed certainly in the next release, so don’t  
waste your time trying to make it work.

---

<div class="post-metadata">

**Author:** ![futlib](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/7ea924/32.png) [@futlib](https://www.ruby-forum.com/u/futlib)\
**Post date:** [March 25, 2009, 12:08pm UTC](https://www.ruby-forum.com/t/rails-2-3-2-apache2-and-cgi-not-working/163725/3 "2009-03-25T12:08:15Z")

</div>

Fernando P. wrote:

> Fut Lib wrote:
> 
> > Hi,
> > 
> > I am trying to deploy a trivial rails application on an apache server,  
> > using the, as I understand obsolete, CGI way.
> 
> CGI support will be removed certainly in the next release, so don’t  
> waste your time trying to make it work.

Fair enough. I was actually looking for an easy solution to use rails  
and e.g. php apps in the same vhost.

Setting up some mongrel rails server for a single trivial rails  
application seemed like overkill.

Passenger is basically exactly what I’m looking for, except that it is  
probably not exactly stable in the debian sense and seems to conflict  
with mod\_rewrite which I really can’t have.

Is there anything else?  
Otherwise, I suppose I’ll have to go with mongrel anyways until  
passenger is mature.

---

<div class="post-metadata">

**Author:** ![futlib](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/7ea924/32.png) [@futlib](https://www.ruby-forum.com/u/futlib)\
**Post date:** [March 25, 2009, 1:31pm UTC](https://www.ruby-forum.com/t/rails-2-3-2-apache2-and-cgi-not-working/163725/4 "2009-03-25T13:31:16Z")

</div>

Sorry for double posting.

I ended up using mod\_passenger, and after some obstacles, it worked  
fine.

There’s a number of bugs I’ve worked around and which should really be  
fixed:  
[http://code.google.com/p/phusion-passenger/issues/detail?id=169&q=rails\_relative\_url\_root&colspec=ID%20Type%20Status%20Priority%20Milestone%20Stars%20Summary](http://code.google.com/p/phusion-passenger/issues/detail?id=169&q=rails_relative_url_root&colspec=ID%20Type%20Status%20Priority%20Milestone%20Stars%20Summary)  
[http://code.google.com/p/phusion-passenger/issues/detail?id=13](http://code.google.com/p/phusion-passenger/issues/detail?id=13)

Not to mention the alleged problems with mod\_rewrite and mod\_alias.

But other than that, I can really recommend this solution, works like a  
charm!

Fut Lib wrote:

> Fernando P. wrote:
> 
> > Fut Lib wrote:
> > 
> > > Hi,
> > > 
> > > I am trying to deploy a trivial rails application on an apache server,  
> > > using the, as I understand obsolete, CGI way.
> > 
> > CGI support will be removed certainly in the next release, so don’t  
> > waste your time trying to make it work.
> 
> Fair enough. I was actually looking for an easy solution to use rails  
> and e.g. php apps in the same vhost.
> 
> Setting up some mongrel rails server for a single trivial rails  
> application seemed like overkill.
> 
> Passenger is basically exactly what I’m looking for, except that it is  
> probably not exactly stable in the debian sense and seems to conflict  
> with mod\_rewrite which I really can’t have.
> 
> Is there anything else?  
> Otherwise, I suppose I’ll have to go with mongrel anyways until  
> passenger is mature.

---

<div class="post-metadata">

**Author:** ![futlib](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/7ea924/32.png) [@futlib](https://www.ruby-forum.com/u/futlib)\
**Post date:** [July 16, 2009, 11:55am UTC](https://www.ruby-forum.com/t/rails-2-3-2-apache2-and-cgi-not-working/163725/5 "2009-07-16T11:55:43Z")

</div>

No solution yet.  
But I did a freeze on 2.2.2 to get it back working and I’m on my way to  
find a new host. Considering [hostingrails.com](http://hostingrails.com)

Cheers

---

<div class="post-metadata">

**Author:** ![futlib](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/7ea924/32.png) [@futlib](https://www.ruby-forum.com/u/futlib)\
**Post date:** [July 14, 2009, 11:54pm UTC](https://www.ruby-forum.com/t/rails-2-3-2-apache2-and-cgi-not-working/163725/6 "2009-07-14T23:54:25Z")

</div>

Hi,

My host (Bluehost) just upgraded to 2.3.2 and I’m now completely lost on  
what to do next 😛

I get the same error as intially posted here.

/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action\_controller/cgi\_process.rb:22:in  
` __send__': undefined method`env\_table’ for nil:NilClass  
(NoMethodError)

I was using CGI.  
Could someone give a brief description of how to solve the issue?  
I have virtual server I can’t completely control everything there.  
Do I have to ask the host to install anything new? I found out that I  
can install the gem rack, do I need to use that?

Any hints?

Thanks.
