Revising dispatch.cgi to run Rails applications?

Hi,

I am trying to set up Ruby on Rails with FastCGI for Apache 2 on Linux. I am followoing instructions here -- http://it.kndb.net/entry/show/id/79. But step 4 is confusing me. It reads:

4. Revise various setting file Basically, confirm that mod_fcgi module of Apache is available and change dispatch.cgi into dispatch.cgi at the .htaccess of Rails application to run Ruby on Rails.

It does not elaborate further. What does the above mean? How do I modify the .htaccess/dispatch.cgi file?

Thanks, - Dave

Thanks for this. I'm still having some issues. Would you mind posting your httpd.conf file, or at least the parts that pertain to RoR?

Again, I appreciate your help, - Dave

laredotornado@zipmail.com wrote:

Thanks for this. I'm still having some issues. Would you mind posting your httpd.conf file, or at least the parts that pertain to RoR?

The setup given below is tested and works. However, it is for Apache 2.0.x and not for Apache 2.2.x and is for fcgid and not fcgi. Also, I use ssl even in development so that this configuration is for https. You can remove all the ssl stuff and the rewrties used to force ssl but I am providing you with a working configuration so I am not going to guess at what parts I can remove safely. If I have missed something significant then please forgive me, I set all this up more than a year ago.

Generally, I do not modify conf/httpd.conf, I split things out into functionally distinct configuration files that I then place in conf.d or virtual.d as appropriate and which are loaded by these conf/httpd.conf directives:

# Load config files from the config directory "/etc/httpd/conf.d". Include conf.d/*.conf # 2007 March 07 - Load virtual server config files from /etc/httpd/virtual.d Include virtual.d/*.conf

However, setup for mod_fcgid is an exception to this, probably because I did it a very long time ago and have changed styles since. The entry I presently have in httpd.conf for this is:

# 2005 Mar 04 JBB8 - added mod_fcgid LoadModule fcgid_module modules/mod_fcgid.so <IfModule mod_fcgid.c>   AddHandler fcgid-script .fcgi   SocketPath /tmp/fcgid_sock   IdleTimeout 3600   ProcessLifeTime 7200   MaxProcessCount 8   DefaultMaxClassProcessCount 2   IPCConnectTimeout 8   IPCCommTimeout 60 </IfModule>

Pay attention to directives that may be wrapped across lines by the message editor. In conf.d I have this:

$ cat conf.d/ruby_rails.conf

# BOF # 2006 Mar 04 JBB8 - added mod_ruby LoadModule ruby_module modules/mod_ruby.so

# ClearModuleList

<IfModule mod_ruby.c>   RubyRequire apache/ruby-run   RubySafeLevel 0

  # For rails   <Files *.rb>   SetHandler ruby-object   RubyHandler Apache::RubyRun.instance   </Files>

  # Execute files under /ruby as Ruby scripts   <Location /ruby>   SetHandler ruby-object   RubyHandler Apache::RubyRun.instance   </Location>

  # Execute *.rbx files as Ruby scripts   <Files *.rbx>   SetHandler ruby-object   RubyHandler Apache::RubyRun.instance   </Files> </IfModule>

# for eruby <IfModule mod_ruby.c>   RubyRequire apache/eruby-run

  # Handle files under /eruby as eRuby files   <Location /eruby>   SetHandler ruby-object   RubyHandler Apache::ERubyRun.instance   </Location>

  # Handle *.rhtml files as eRuby files   <Files *.rhtml>   SetHandler ruby-object   RubyHandler Apache::ERubyRun.instance   </Files> </IfModule>

<Directory /var/www/eruby>     Options ExecCGI </Directory> # EOF

In virtual.d I have:

$ cat virtual.d/ca.harte-lyne.testheart.conf

# BOF

# ca.harte-lyne.testheart.conf 2007 Mar 21 James B. Byrne JBB8