Install problems: R-o-R on Debian with mod_ruby


#1

Hello,
I have tried to setup Ruby-on-rails on my debian Linux machine and can
not get it to run. Maybe someone can help.

The following was installed already:

  • apache2 2.0.54 (and PHP5)
  • Postgresql 8.1

Now, having the ‘unstable’ branch in my /etc/apt/sources.list I did:

apt-get install libapache2-mod-ruby

and Apache reports a “mod_ruby/1.2.4 Ruby/1.8.4” successfully. Then:

apt-get install rails

that finished without errors (installing ruby 1.8.3 on the way).

What follows gave me a deja-vu of Lotus Domino: Lots of helpful people
writing lots of helpful hints in lots of places, nicely linked to other
helpful sites - but no one willing to take over the responsibility for a
complete, consistent documentation. In detail:

This site: http://wiki.rubyonrails.com/rails/pages/Tutorial gives an
“Apache configuration example for Apache 2” that I put into my
apache2.conf (debian equivalent to httpd.conf).
Also I configured mod_ruby according to
http://wiki.modruby.net/en/?InstallGuide

This seems to configure apache to accept .rbx files as ruby-executables,
right? (I later changed that to .rb without success.)

Now rails was installed to /usr/share/rails - in order to access this
from my DocumentRoot /var/www/ I moved that to /var/www/ruby/rails
Then apache2.conf was set up with:
<Directory /var/www/ruby/>
Options ExecCGI SymLinksIfOwnerMatch
AddHandler cgi-script .cgi

The tutorial nows says ‘Go to http://rails/ … and check that you get
the â??Congratulations, youâ??re on Rails!â? screen.’
You guessed right, that didn’t come up (my path being
myhost://ruby/rails).
Now I don’t see what script (index.rb? where?) should bring up this
message.
So I stepped back from getting rails to work and decided to see mod_ruby
work at first: On
http://www.rubycentral.com/book/web.html
I found a simple “hello world” script and put that into
/var/www/ruby/index.rb - but this brings up just the source code, the
same with an index.rbx .

At this point I would believe apache expected something like a:
‘AddType application … .rb’ (or .rbx …)
in a place like /etc/apache2/mods-enabled/ruby.conf .
Now ruby.load exists there and works as we have seen (LoadModule
ruby_module …) - but not ruby.conf.
Should this be added manually (alternatively in apache2.conf)?
Or does rails (on Debian) have a different way to configure apache2 to
understand what to do with .rb (or whatever ruby-)files?
Or maybe the Debian ‘rails’ package is not meant to be installed
together with mod_ruby and works only with fast-CGI?

Thanks for hints !
// Bernd


#2

Hi!

Are you new to rails? So , why don’t ou first use WebBrick to develop,
and after this try to setup apache with ruby?

Theres no configuration point to /usr/share/rails . You first need to
create an rails application, running the command

cd /var/www

rails ruby (or another name that you want)

This installs rails to you on /var/www/ruby. After this, you can try and
go to http://localhost/ruby .

I hope it works, sometimes you need to install more packages.

But if you just want to play with rails, at directory /var/www/ruby run

./script/server

Then go to http://localhost:3000 , and you will see the welcome page of
rails. Then, you can start to play!

After, when you really go use apache, you will want to use fastcgi, that
is really better than mod_ruby.

I hope this helps you,

filipe

Em Qua, 2005-12-14 Ã s 23:59 +0100, Bernd vdB escreveu:


#3

On Wed, 2005-12-14 at 23:59 +0100, Bernd vdB wrote:

Hello,
I have tried to setup Ruby-on-rails on my debian Linux machine and can
not get it to run. Maybe someone can help.

snip

debian, which we know and love, has a completely different package
system than other linux distros, as I am sure you know. This means that
the traditional means of installing rails through ruby-gems (ruby’s
package system) will not work out-of-the-box. Furthermore I am unsure if
you can enable rails solely through mod_ruby, I think you need to drop
into apt-get first.

On my Ubuntu (Warty) system I had to apt-get a bunch of other packages,
like libyaml-ruby and libzlib-ruby before I could get gems installed. I
managed to get gems installed and rails installed but rails is now
complaining when I try to build it. People on this list have advised
that I compile ruby from scratch instead. That seems unnecessary, but
perhaps the only route.

I will try to stay in touch and maybe we can find and develop some more
resources for debian / ubuntu types who are insterested in ruby and
rails, since rails is popular and so is debian.

Regards,

Jeremiah

Jeremiah Foster
removed_email_address@domain.invalid


#4

Hi all,
here how to setup ror on a debian 3.1 :

apt-get install ruby
apt-get install ruby1.8-dev
apt-get install rdoc

dowload ruby gem.
run setup.rb

gem install rake --include-dependencies --http-proxy ourproxy
apt-get install libopenssl-ruby1.8

gem install rails --include-dependencies
gem install mysql (should work, if it didn’t :
cd :/usr/lib/ruby/gems/1.8/gems/mysql-2.7
ruby extconf.rb
make
make install

apt-get install apache2
apt-get install libapache2-mod-fastcgi
apt-get install libfcgi-ruby1.8

in
/etc/apache2/sites-availables make a ror file whith

ServerName ror.artprice.bil
DocumentRoot /var/www/app/public/
ErrorLog /var/www/app/log/server.log

    <Directory      /var/www/app/public/>
            Options ExecCGI FollowSymLinks
            AllowOverride   all
            Allow           from all
            Order           Allow,Deny

    </Directory>
then ln /etc/apache2/sites-available/ror /etc/apache2/sites-enabled/001-ror -s ln /etc/apache2/mods-available/fastcgi.load /etc/apache2/mods-enabled/ -s ln /etc/apache2/mods-available/fastcgi.conf /etc/apache2/mods-enabled/ -s

fastcgi.conf :

AddHandler fastcgi-script .fcgi
#FastCgiWrapper /usr/lib/apache2/suexec2
FastCgiIpcDir /var/lib/apache2/fastcgi
FastCgiServer /root/app/public/dispatch.fcgi
-initial-env RAILS_ENV=production
-processes 5 -idle-timeout 60

in public/.htaccess
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

activate rewrite modul from apache2
ln /etc/apache2/mods-available/rewrite.load …/mods-enabled/ -s

U should change session storage activerecord to avoid writing problem to
tmp.
if something dont work, try the log in app/log and the apache one !
a simpler solution is to use lighthttp.

Jeremiah Foster wrote:

complaining when I try to build it. People on this list have advised

“Ce message et toutes les pièces jointes sont des informations
strictement confidentielles et réservées au(x) destinataire(s). Ce
courriel n’a pas de valeur contractuelle et son contenu ne constitue ni
une acceptation, ni un engagement de la part de l’auteur et des sociétés
du groupe Serveur et Artprice, sauf dans le cas où cela aurait été prévu
avec le destinataire par un accord écrit. Le contenu de ce message et
les pièces jointes ne peuvent constituer une preuve au sens de l’article
1316-1 du Code Civil. L.auteur et les sociétés du groupe Serveur et
Artprice déclinent toute responsabilité au titre de ce courriel s’il a
été altéré, déformé, falsifié ou indûment utilisé par des tiers ou
encore s’il a causé tout dommage ou perte de toute nature. Si vous
n’êtes pas le bon destinataire, merci de nous contacter et de ne pas le
divulguer.”

“This message including any attachments are confidential and privileged
material intended solely for the addressees. Its contents do not
constitute a commitment by groupe Serveur sas and Artprice SA, except
when provided for in a written agreement with the addressees. The
contents of this message cannot constitute neither the proof nor the
acceptance of any agreement as per article 1316-1 of the French civil
code.
Groupe Serveur sas and Artprice SA shall not be rendered liable in any
manner whatsoever for the delay and/or loss in transit of this message,
for corruption, alteration, falsification, misuse or fraudulent use
(which may be made) of this message. If you receive this message in
error, please delete it and immediately notify the sender. If the reader
of this message is not the intended recipient, you are hereby notified
that any unauthorized use, copying or dissemination is prohibited.”


#5

Jeremiah Foster wrote:

debian, which we know and love, has a completely different package
system than other linux distros, as I am sure you know.

Sure. Still, the maintainer of the debian rails package should have had
some idea of what he is doing.

This means that
the traditional means of installing rails through ruby-gems (ruby’s
package system) will not work out-of-the-box.

Fine, I didn’t even try this.

Furthermore I am unsure if
you can enable rails solely through mod_ruby, I think you need to drop
into apt-get first.

Please read my post.
After ‘apt-get mod_ruby’ I did ‘apt-get rails’ - without errors.

… maybe we can find and develop some more
resources for debian / ubuntu types who are insterested in ruby and
rails, since rails is popular and so is debian.

The debian rails package exists - what is missing is a complete
documentation for it - i.e. considering fastCGI as well as mod_ruby
variants.


#6

Christophe V. wrote:

… here how to setup ror on a debian 3.1 :

dowload ruby gem.
run setup.rb

gem install rake --include-dependencies --http-proxy ourproxy

apt-get install libapache2-mod-fastcgi

fastcgi.conf :

Ok, so you opted for a completely different setup.
Unfortunately, this doesn’t help me.


#7

Hi,
Filipe Lautert wrote:

Are you new to rails? So , why don’t ou first use WebBrick to develop,
and after this try to setup apache with ruby?

I have no doubt that r-o-r is a powerful web-app framework.
What I evaluate now is precisely the way to set it up, maintain and use
it on a live webserver, based on apache and mod_ruby.

Theres no configuration point to /usr/share/rails . You first need to
create an rails application, running the command

rails ruby (or another name that you want)

Great, this worked (created a couple of subdirs/files under ruby/)

This installs rails to you on /var/www/ruby. After this, you can try and
go to http://localhost/ruby .

This gives a 500 server error (as mentioned on the mod_ruby site).
Because, once again, there is no index.rb or something like it in /ruby

Which brings a:
Application error - Rails application failed to start properly

Looks like at least some sort of ruby code hab been activated - but no,
it’s just a different errorDocument 500 out of .htaccess …

Anybody out there with mod_ruby experience?

… if you just want to play with rails, at directory /var/www/ruby run

./script/server

Then go to http://localhost:3000 , and you will see the welcome page of
rails. Then, you can start to play!

This works, so it’s a webserver running on ruby, right?
Nice, but I would like to get apache/mod_ruby working …

After, when you really go use apache, you will want to use fastcgi, that
is really better than mod_ruby.

Why? mod_ruby is going to start faster than (any) CGI, that’s why it is
considered first choice for life web-apps. At least this is the wisdom
for perl, python etc. Any references about this question?


#8

Why? mod_ruby is going to start faster than (any) CGI, that’s why it
is
considered first choice for life web-apps. At least this is the wisdom
for perl, python etc. Any references about this question?

Well, was just a sugestion. You can take a look at
http://blog.shugo.net/articles/2005/08/04/mod_ruby-vs-fastcgi-on-rails ,
This can help to take a decision.

filipe


#9

On Thu, 2005-12-15 at 12:09 +0100, Bernd vdB wrote:

Jeremiah Foster wrote:

debian, which we know and love, has a completely different package
system than other linux distros, as I am sure you know.

Sure. Still, the maintainer of the debian rails package should have had
some idea of what he is doing.

Of course they know what they are doing. Because you can’t get it to
work do not blame the maintainer.

This means that
the traditional means of installing rails through ruby-gems (ruby’s
package system) will not work out-of-the-box.

Fine, I didn’t even try this.

Well . . .maybe you should. I think you are really confusing rails with
mod_ruby. Look more closely at both packages to discern the differences.

Furthermore I am unsure if
you can enable rails solely through mod_ruby, I think you need to drop
into apt-get first.

Please read my post.
After ‘apt-get mod_ruby’ I did ‘apt-get rails’ - without errors.

The point is why did you do that?

… maybe we can find and develop some more
resources for debian / ubuntu types who are insterested in ruby and
rails, since rails is popular and so is debian.

The debian rails package exists - what is missing is a complete
documentation for it - i.e. considering fastCGI as well as mod_ruby
variants.

Maybe you can write that.

Jeremiah Foster
removed_email_address@domain.invalid


#10

Hello Jeremiah,
sorry I did not mean to insult anybody - but basically I am looking for
someone who knows about mod_ruby and r-o-r and not for a discussion on
my posting style.

Jeremiah Foster wrote:

… Because you can’t get it to work do not blame the maintainer.

I am not blaming him, just asking (someone) for explanation how this is
supposed to work.

… ruby-gems (ruby’s package system) …

Fine, I didn’t even try this.

Well . . .maybe you should.

No, a ruby package manager will not solve the problem that is connected
to mod_ruby.

Please read my post.
After ‘apt-get mod_ruby’ I did ‘apt-get rails’ - without errors.

The point is why did you do that?

No, this is not the point of this thread.
But, once again: I did it because I want to find out about
r-o-r-with-mod_ruby.

… - what is missing is a complete documentation for it - …

Maybe you can write that.

Yes, after I understand how it’s meant to work.
This is why I was asking here.


#11

Hello Bernd,

It’s not that there is a lack of documentation, it seems to be that you
are refusing to look at it.

After creating your rails app with something like rails [myapp], read
the README file that is created, and use the example for apache to help
you configure apache for your rails app. The main thing is that you
want
apache to point at the public directory in your rails app.

One you have this working, you can edit the .htaccess file in the public
directory to choose which dispatcher you would like to use (cgi,
fastcgi,
or mod_ruby).

I hope this helps.
Ken…


#12

Ken B. wrote:

It’s not that there is a lack of documentation, it seems to be that you
are refusing to look at it.

Hm, sorry, but I read everything that I found on the issue.
But I found no details about the combination of r-o-r and mod_ruby.
Thats why I’m asking here.

After creating your rails app with something like rails [myapp], read
the README file that is created, and use the example for apache to help
you configure apache for your rails app. The main thing is that you
want apache to point at the public directory in your rails app.

I read that and did everything ok, as far as I can see.
Still, going to http://myhost/ruby brings a 500 Error - the one that is
mentioned here:
http://wiki.modruby.net/en/?InstallGuide

Only the solution from there (‘RedirectMatch …’) is not applicable
because an ‘index.rb’ does not exist in /ruby or elsewhere.

Is there a test.rb or something similar somewhere in the r-o-r tree?

One you have this working, you can edit the .htaccess file in the public
directory to choose which dispatcher you would like to use (cgi,
fastcgi, or mod_ruby).

Ok, what would I write into that for mod_ruby ?

Thanks !
// Bernd


#13

On Thu, 15 Dec 2005, Bernd vdB wrote:

I read that and did everything ok, as far as I can see.
Still, going to http://myhost/ruby brings a 500 Error - the one that is
mentioned here:
http://wiki.modruby.net/en/?InstallGuide

Only the solution from there (‘RedirectMatch …’) is not applicable
because an ‘index.rb’ does not exist in /ruby or elsewhere.

Is there a test.rb or something similar somewhere in the r-o-r tree?

If you look in the public/.htaccess file, you will see a line that looks
like this:

RewriteRule ^(.*)$ dispatch.cgi [QSA,L]

… change this to look like this:

RewriteRule ^(.*)$ dispatch.rb [QSA,L]

As a disclaimer, I don’t use mod_ruby with rails. I do run Debian (sid
and testing) with apache and apache2 on different machines, but use
fastcgi. I also use webrick for local development before deploying on
an
apache server. Let me know if this still doesn’t work for you, and I
will
see if I can set up rails with mod_ruby on my development machine to
confirm that it works.

Ken…


#14

On Dec 15, 2005, at 2:59 AM, Bernd vdB wrote:

it on a live webserver, based on apache and mod_ruby.

try and

Why? mod_ruby is going to start faster than (any) CGI, that’s why
it is
considered first choice for life web-apps. At least this is the wisdom
for perl, python etc. Any references about this question?

 The main drawback of mod_ruby is that you cannot run 2 rails apps

on the same server under mod_ruby. Rails is not exactly thread safe
and mod_ruby uses one global ruby interpreter for processing requests
it seems. So if you have 2 rails apps they start to infringe on each
other.

The preferred way to run rails applications and what they are

optimized for is fastCGI. It may take a little bit longer to start up
the fcgi processes when the webserver is rebooted, but fcgi runs your
rails apps from persistent memory. meaning that the whole framework
is loaded into memory already and requests can be processed very fast.

I have set up mod_ruby and eruby before with apache before rails was

out. I can tell you from personal experience that fastcgi is the way
to go. FOrget about mod_ruby unless you just want to server plain
ruby pages or eruby pages without rails. I don’t know of anyone that
is running rails in a mod_ruby environment. FastCGI or SCGI are
really the only viable options at this point. Although I have heard
that the author of mod_ruby is trying to make it a viable option
which would be nice, but it hasn’t happened yet.

Also I and many others prefer to run our rails apps under lighttpd/

fastcgi as lighttpd is faster then apache. If you must keep apache
you can set up a vhost that will proxy the requests through to a
local lighttpd server running your rails app on a higher port.

Good luck with whatever setup you decide to go with. But some

friendly advice is to now waste your time trying to run rails under
mod_ruby until a newer version comes out that addresses these issues.
FastCGI is a tried and true way to run rails and it is the defacto
standard.

Cheers-
-Ezra Z.
Yakima Herald-Republic
WebMaster
http://yakimaherald.com
509-577-7732
removed_email_address@domain.invalid


#15

Hello Ken,
you wrote:


Is there a test.rb or something similar somewhere in the r-o-r tree?

If you look in the public/.htaccess file, …
… change this to look like this:

RewriteRule ^(.*)$ dispatch.rb [QSA,L]

I did this, but http://myhost/ruby/public still produces the 500 Error.

As a disclaimer, I don’t use mod_ruby with rails. I … use
fastcgi. I also use webrick for local development …

Ok, I understand Webrick IS the test for a rails installation and there
is no (other) test.rb or similar script for that purpose.

Thanks for your offer to debug my setup further, but after what Ezra
wrote I decided to stop fighting the r-o-r-mod_ruby windmills …

So I just did:
apt-get remove libapache2-mod-ruby
apt-get remove rails

… cleaned my apach2.conf - and will start again next week on the
ruby-fastCGI track. Should there be any problems with that I will pop up
here again.
Thanks for the hints everybody.
// Bernd