Ruby on Rails on Linux - Any suggestions/Help?

Hi, I’m really new to RoR and I’m trying to setup a development or even
production server for Ruby on Rails.

I’m trying to do it on Linux Debian, but somehow, I always get this
Error:

Application Error - Rails application failed to start properly

This was running on Debian Linux, Apache2, Mysql and FastCGI.

The Tutorial I used:
http://o9y.net/archives/2006/02/17/ruby-on-rails-mittels-mod_fcgi-fur-apache
-2-unter-debian/ (German)

Well, I installed everything as described in one of those many tutorials
on
the net, but I don’t get it to work.

Maybe someone has some tips I schould do to get it work? Or maybe
someone
might tell me what Setup might be the best on Linux???

I always worked with Debian, but I could switch to any other if someone
tells me which might be the best for this task.

Thanks

-Georges

Check your logs, development.log for rails and the apache logs. Try
your app in webrick.

~ Ben

On 5/8/06, Jentgen Georges jr. [email protected] wrote:

Application Error - Rails application failed to start properly

http://lists.rubyonrails.org/mailman/listinfo/rails


Ben R.
303-947-0446
http://www.benr75.com

Well,

It seems that there might be a problem with my FastCGI installation for
Apache. This is in my log/error.log from my rails Project:

FastCGI: incomplete headers (0 bytes)

ruby 1.8.2 (2005-04-11) [i386-linux]
Rails 1.1.2

-Georges

Jentgen Georges jr.
escribió:> Rails 1.1.2
Hi Georges,

I use Debian/testing (2.6.8-2-386) and I have a protocol to set up an
application with virtual hosts (Apache) Is in spanish (don’t have too
much time in this moment to translate it, sorry) see it attached below:

  1. Tomamos como ejemplo el tutorial Four days on rails

  2. Como root en /var/www/:
    #rails ToDo

  3. Con el phpnyadmin creamos la base de datos ‘todos’ y la tabla
    ‘categories’

  4. En /var/www/ToDo/ (de ahora en adelante ~/ToDo) hacemos:
    #ruby script/generate scaffold category

  5. Editamos ~/ToDo/config/database.yml y ponemos:

      development:
      adapter: mysql
      database: todos
      username: root
      password:
      socket: /var/run/mysqld/mysqld.sock
    
  6. Editamos ~/ToDo/public/.htaccess y quitamos el símbolo ‘#’ de las
    líneas sgtes.:

      RewriteCond %{REQUEST_URI} ^/notrails.*
      RewriteRule .* - [L]
      RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
      RewriteEngine On
    
      Dejamos el resto tal como está 
    
  7. En /etc/apache2/sites-available/default introducimos al final:

      <VirtualHost *>
      ServerName todo
      DocumentRoot /var/www/ToDo/public
      ErrorLog /var/www/ToDo/log/apache.log
      <Directory /var/www/ToDo/public/>
      Options +ExecCGI +FollowSymLinks
      AddHandler fcgid-script .fcgi
      AllowOverride all
      Order allow,deny
      Allow from all
      </Directory>
      </VirtualHost>
    
  8. En /etc/apache2/apache2.conf quitamos el símbolo ‘#’ de la línea:

      AddHandler fastcgi-script .fcgi .fcg .fpl
    
  9. No olvidar reiniciar el servidor apache cuando hagamos cualquier
    cambio:

      #apache2ctl restart
    
  10. No olvidar añadir en /etc/hosts el nombre del nuevo host (todos) y
    tampoco de los permisos en /var/www/todos/ de forma: chmod -R 777 *
    /todos

Hope this helps

Antonio

On Mon, May 08, 2006 at 09:39:48PM +0200, Jentgen Georges jr. wrote:
} Hi, I’m really new to RoR and I’m trying to setup a development or
even
} production server for Ruby on Rails.
}
} I’m trying to do it on Linux Debian, but somehow, I always get this
Error:
}
} Application Error - Rails application failed to start properly
}
} This was running on Debian Linux, Apache2, Mysql and FastCGI.

Apache2 does not play nicely with mod_fastcgi. You need mod_fcgid.
Conveniently, this involves just apt-get install libapache2-mod-fcgid.

} The Tutorial I used:
}
http://o9y.net/archives/2006/02/17/ruby-on-rails-mittels-mod_fcgi-fur-apache-2-unter-debian/
(German)
[…]

I don’t know German, I’m afraid, but it appears that the tutorial is
having
you build mod_fastcgi yourself. I’m not sure why, since it is available
precompiled as a Debian package. More to the point, it doesn’t work
particularly well with Apache2.

} Maybe someone has some tips I schould do to get it work? Or maybe
someone
} might tell me what Setup might be the best on Linux???

Apache2 is fine. Debian is great. MySQL… eh, to each his own. FastCGI
is
a good choice in other environments, but you need mod_fcgid. A quick
Google
search for mod_fcgid and rails gives a number of pages with useful
information. That said, here’s what I have in
/etc/apache2/sites-available/default (note that this is for an app
running
at a path on a main server rather than as its own virtual host, as shown
on
the Alias line):

DefaultInitEnv RAILS_ENV production Alias /bookmarkfeeds /home/gss/work/ruby/bookmarkfeeds/public Options ExecCGI +FollowSymLinks AllowOverride All order allow,deny allow from all RedirectMatch ^/bookmarkfeeds/$ /bookmarkfeeds/feeds/ RedirectMatch ^/bookmarkfeeds$ /bookmarkfeeds/feeds/

Note that those last two RedirectMatch lines are specific to my app, and
don’t apply in general. And yes, I am running it out of my home
directory,
because I feel like it. In addition, I had to modify the
RAILS_ROOT/public/.htaccess file to change the following two lines (they
are not contiguous in the file):

AddHandler fastcgi-script .fcgi
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]

…to…

AddHandler fcgid-script .fcgi
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

Finally, since I have this running at /bookmarkfeeds instead of at / I
needed this line in the .htaccess file as well:

RewriteBase /bookmarkfeeds

} I always worked with Debian, but I could switch to any other if
someone
} tells me which might be the best for this task.

There will always be people who think that their system is better than
yours. I can assure you that it is possible and even moderately easy to
get
mod_fcgid working with Rails and Apache2 under Debian. I’ve done it. I
have
it running on my own machine.

} Thanks
} -Georges
–Greg