RoR on Apache2

Hello,

I’ve been going though the “4 Days on Rails” tutorial at
http://rails.homelinux.org/ test-driving ruby on rails using the WEBrick
server without problems. I’m trying to move the app to be seen by
apache2, and am having some troubles. I’ve looked through many guides
online which all say pretty much the same thing, which, I think, I am
doing.

Anyway, the debug information is below that I believe is pertinent.

Any thoughts? Thanks.
-Chad

Ubuntu 6.06, Apache/2.0.55 (Ubuntu) PHP/5.1.2, ruby 1.8.4 (2005-12-24)
[i486-linux], Rails 1.1.2

The app is located at /home/crvoelker/src/ToDo/

—start segment---- /etc/apache2/apache2.conf

#AddHandler cgi-script .cgi
AddHandler fcgid-script .fcgi

Alias /ToDo/ “/home/crvoelker/src/ToDo/public/”
<Directory “/home/crvoelker/src/ToDo/public/”>
Options Indexes MultiViews ExecCGI FollowSymLinks
AddHandler cgi-script .cgi
AddHandler fcgid-script .fcgi .fcg .fpl
AllowOverride All
Allow from all
Order allow,deny

—end segment---- /etc/apache2/apache2.conf

—start segment---- /home/crvoelker/src/ToDo/public/.htaccess
RewriteEngine On
RewriteBase /ToDo
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
ErrorDocument 500 “

Application error

Rails application failed to
start properly”

—end segment---- /home/crvoelker/src/ToDo/public/.htaccess

$ a2enmod fcgid
This module is already enabled!

$ dpkg --get-selections | grep cgi
libapache2-mod-fcgid install
libfcgi-dev install
libfcgi-ruby1.8 install
libfcgi0 install

$ sudo gem install fcgi
Attempting local installation of ‘fcgi’
Local gem file not found: fcgi*.gem
Attempting remote installation of ‘fcgi’
Building native extensions. This could take a while…
extconf.rb:3:in `require’: no such file to load – mkmf (LoadError)
from extconf.rb:3
ERROR: While executing gem … (RuntimeError)
ERROR: Failed to build gem native extension.
Gem files will remain installed in
/usr/lib/ruby/gems/1.8/gems/fcgi-0.8.6.1 for inspection.
ruby extconf.rb install fcgi\n

Results logged to
/usr/lib/ruby/gems/1.8/gems/fcgi-0.8.6.1/ext/gem_make.out

any reason you need to use apache 2? Pretty much everything I’ve read
so far has nothing but bad things to say about rails with apache 2…
I’ve beenusing it with 1.3 with no problems…

Mike

Hmmm, bummer. Any reason? No, not really. I’m building a new server to
replace my Mandrake system, so I was hoping to get the all the latest
(read: stable) stuff. I didn’t know that Apache 2 was still going
through growing pains.

I guess, if ever, now would be the time to revert. Well, if I don’t get
any reasonable responses here, I will make that change.

Thanks for your comments.
-Chad

Mike G. wrote:

any reason you need to use apache 2? Pretty much everything I’ve read
so far has nothing but bad things to say about rails with apache 2…
I’ve beenusing it with 1.3 with no problems…

Mike

There’s nothing wrong with Apache 2.0 it’s fastcgi under Apache 2.0
that’s not so hot.

Apache 2.0 with fcgid is a good choice if you needs something simple and
relatively fast.

Apache 2.2 with Mongrel is a great choice if you need something very
configurable with excellent performance and lots of options.

Of course there are excellent non Apache choices also.

I’ve done some reasearch on the apache1.3 -vs- apache2 debate, and I’ve
concluded that since I am using the (non-threaded) prefork mpm, I should
be safe from most of the apache2 criticisms that I’ve found.

Getting back to your latest post, I am using fcgid with apache 2. All of
which, I would have to assume has little effect, since removing the
“AddHandler fcgid-script” line from the apache2.conf and changing the
.htaccess line from RewriteRule ^(.)$ dispatch.fcgi [QSA,L] to
RewriteRule ^(.
)$ dispatch.cgi [QSA,L] has no change in the error
message:

“Application error
Change this error message for exceptions thrown
outside of an action (like in Dispatcher setups or broken Ruby code) in
public/500.html”

I’m convinced this is a configuration issue. If you could advise me of
any RoR log files or other debugging method that would be great. The
apache logs don’t tell me anything.

A little history: I’m attempting to find a ajax capable replacement for
a standard php application. (One that doesn’t require me to roll my own
Ajax javascript) I’m looking at some php frameworks and Rails.
Unfortunately, if I can’t get past this config issue, rails cannot be my
solution. :frowning:

I’ve also joined my local rails user group. I will attempt to post this
issue there also.

Seriously, thanks for both your time up to this point.
-Chad

Michael G. wrote:

Mike G. wrote:

any reason you need to use apache 2? Pretty much everything I’ve read
so far has nothing but bad things to say about rails with apache 2…
I’ve beenusing it with 1.3 with no problems…

Mike

There’s nothing wrong with Apache 2.0 it’s fastcgi under Apache 2.0
that’s not so hot.

Apache 2.0 with fcgid is a good choice if you needs something simple and
relatively fast.

Apache 2.2 with Mongrel is a great choice if you need something very
configurable with excellent performance and lots of options.

Of course there are excellent non Apache choices also.

Alan F. wrote:

None of the above debate on Apache1.3 vs Apache2.0 is addressing the
problem, which seems to be related to installing the fcgi gem ?

See this post for a possible explanation.

From the desk of Peter Hoeg

…but as an aside, I’ve been running Apache2.0 with mod_fastcgi just
fine for a while now. It doesn’t seem to scale very well, but I’m not
using it for anything heavy. It shouldn’t stop you getting started and
practicing for production deployment.

Alan

when I said that I’ve heard nothing but bad things about rails and
apache 2, I was indeed referring to fastcgi support. I haven’t
actually tried setting up apache 2, so I don’t have any first hand
experience with it, but it was the following post which caused me to
go with apache 1.3 instead:

http://duncandavidson.com/essay/2006/01/railsonapache

Mike

try chown apache:apache /path.to/railsapp

could be the cause. also check out the The Gentoo Linux | CustomEssayMeister.com
guide. Worked for me flawlessly apache2+fcgid

On Jun 16, 2006, at 6:07 PM, Chad Voelker wrote:

.htaccess line from RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] to
apache logs don’t tell me anything.
I’ve also joined my local rails user group. I will attempt to post

so far has nothing but bad things to say about rails with apache 2…

[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

–ktolis
http://iridium.csd.auth.gr/~ktolis

Chad Voelker wrote:

$ sudo gem install fcgi
Attempting local installation of ‘fcgi’
Local gem file not found: fcgi*.gem
Attempting remote installation of ‘fcgi’
Building native extensions. This could take a while…
extconf.rb:3:in `require’: no such file to load – mkmf (LoadError)
from extconf.rb:3
ERROR: While executing gem … (RuntimeError)
ERROR: Failed to build gem native extension.
Gem files will remain installed in
/usr/lib/ruby/gems/1.8/gems/fcgi-0.8.6.1 for inspection.
ruby extconf.rb install fcgi\n

Results logged to
/usr/lib/ruby/gems/1.8/gems/fcgi-0.8.6.1/ext/gem_make.out

sudo apt-get install libfcgi-dev
sudo gem install fcgi

Michael G. wrote:

Chad Voelker wrote:

$ sudo gem install fcgi
Attempting local installation of ‘fcgi’
Local gem file not found: fcgi*.gem
Attempting remote installation of ‘fcgi’
Building native extensions. This could take a while…
extconf.rb:3:in `require’: no such file to load – mkmf (LoadError)
from extconf.rb:3
ERROR: While executing gem … (RuntimeError)
ERROR: Failed to build gem native extension.
Gem files will remain installed in
/usr/lib/ruby/gems/1.8/gems/fcgi-0.8.6.1 for inspection.
ruby extconf.rb install fcgi\n

Results logged to
/usr/lib/ruby/gems/1.8/gems/fcgi-0.8.6.1/ext/gem_make.out

sudo apt-get install libfcgi-dev
sudo gem install fcgi

I guess you can ignore that I finally went bck and read the first post
for real this time…

If you are installing libfcgi-ruby1.8 from the repository than you do
not want or need the gem. It’s two different ways to get the same
thing.

You don’t need the gem, so the error telling you it didn’t install is
meaningless.

Does it run under cgi?

None of the above debate on Apache1.3 vs Apache2.0 is addressing the
problem, which seems to be related to installing the fcgi gem ?

See this post for a possible explanation.

A.

i think you can’t do that. unless you run apache with that users
permissions… why would you want it to be able to write to your
memspace anyway?..
this way the hacked application could compromise your account…

On Jun 16, 2006, at 9:48 PM, Chad Voelker wrote:

Now works. Seems that it was misreporting not knowing where

[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

–ktolis
http://iridium.csd.auth.gr/~ktolis

Ok, thanks everyone for your help. I got it running with some
combination of the following:

  • $sudo apt-get install gcc libc6-dev libc-dev
    I noticed that the gem install was attempting to do a gcc command,
    and that I didn’t have it installed yet… How could I have possible got
    a running Linux system up to this point without it? :wink:

  • $sudo gem install fcgi
    Now works. Seems that it was misreporting not knowing where
    /usr/include/fcgiapp.h was

  • $sudo chown -R www-data:www-data ToDo

Bingo. No, it was not running under cgi (assuming I was doing everything
right). I’m assuming it was the ownership thang. I had everything
myusername:www-data with the group write bit set, and group-exec on the
.cgi and .fcgi

I’d much prefer myusername:www-data. Anyone got suggestions for the
appropriate file permissions?

Thanks again!
-Chad