Re: Can't get mod_ruby to work

Arnold Daniels <[email protected]> Fri, 16 Nov 2007 19:24:07 +0100
Newsgroups gmane.comp.apache.mod-ruby
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------030408060800040601010800
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi Taylor,

I do not have eruby installed, by as I read on 
http://wiki.rubyonrails.org/rails/pages/mod_ruby, it isn't need it. I 
can install it still if it is useful.

I am testing this on my laptop, which has a very different configuration 
from the destination servers. I am running mpm ITK 
(http://mpm-itk.sesse.net/), which might be part of the problem. I'll 
try it own in the testing environment to see what happens.

Best regards,
Arnold Daniels


Taylor Redden wrote:
> Hi Arnold,
>
> I am currently running a few websites on my server at home using apache.
> One site is in php, two others are in ruby using mod_ruby, not rails though,
> so i'm not sure how much of a help I could be. When looking at my config
> file in apache one thing that popped out was you have no .rhtml handler.
> Also, my .rhtml handler uses eruby. Do you have eruby installed?
>
> Please write back to me, I would love to help you with this problem,
> because I love the Ruby language, and anything to help spread its
> grace I'm down for.
>
> Taylor Redden
> taylorredden.com
>
> PS I do have one rails program up and running, but  apache
> proxies the request to another box that I run the basic web-brick server.
>
> On Nov 15, 2007 2:41 PM, Arnold Daniels <[email protected]> wrote:
>   
>> Hi David,
>>
>> Thanks for you answer. We use pre-fork, so it doesn't matter if Rails
>> isn't thread-safe because each connection will be handled by a different
>> process. We also run PHP as Apache module, which also isn't thread-safe.
>> If I'm missing the point please tell me why.
>>
>> A bit more background information. We run linux a custom kernel patch,
>> which allows switching a specific user (www-data) to switch to another
>> user (>2000) within a process. It also allows switching back, but only
>> by the main process and not child processes. This works great as long a
>> the user can not make custom system calls within the Apache process.
>> That is why we cannot support fcgi. I'm aware that this is not 100%, but
>> it is safe enough. Hack attempts (using buffer overflows) will most
>> likely cause segmentation faults and we have a daemon monitoring that
>> (never happened by the way). For the record, this hack can never make
>> you root, at best you can read/change files of a customer (which would
>> already be pretty bad).
>>
>> However, the current problem doesn't have anything to do with Rails. As
>> soon as I add 'RubyRequire apache/ruby-run' to my Apache config, the
>> server will stop handling any requests. It will still accept
>> connections, but does not more than that. Has anyone seen this behaviour
>> before, or can anyone who know the internals tell me what this might be
>> causing. I you need more information, a strace for example (I didn't see
>> anything in the strace), please tell me.
>>
>> Best regards,
>> Arnold Daniels
>>
>>
>>
>>
>> David Heinemeier Hansson wrote:
>>     
>>> Hi Arnold,
>>>
>>> Rails won't work by default in a mod_ruby environment where multiple
>>> applications are sharing the same setup. mod_ruby shares the Ruby
>>> instance across all the applications and Rails use essentially global
>>> variables that are not compatible with having that information shared
>>> across multiple applications.
>>>
>>> I don't know of any other hosts that takes Rails hosting serious that
>>> are using mod_ruby. Everyone else are using either FastCGI or Mongrel.
>>> Given your constraints, I don't think running Rails is going to be
>>> something you can offer.
>>>
>>> I do know that some experimental support for running Rails under
>>> mod_ruby was done a few years back, but I don't think it solved the
>>> fundamental issue of having a shared Ruby instance, which is not safe.
>>>
>>>       
>>>> To give you a bit of background. I'm setting up a test project to see
>>>> if we can support Ruby on Rails for our hosting company. I need a
>>>> solution which fits in a 100% automated set-up. Tomcat does not and I
>>>> don't know mongrel, but I doubt if it does. Also in our setup the
>>>> Apache process switches to the user, for security purposes, so
>>>> running another daemon is not an option. Supporting fastcgi is also
>>>> not an option for security issues and running it as normal cgi is a
>>>> performance killer. In short I want to run it using mod_ruby. I'm not
>>>> sure how I gave the impression that using mod_ruby or supporting
>>>> Rails was optional, but it's not. Otherwise I would not have posted
>>>> in on the mod_ruby mailing list.
>>>>
>>>> I assume that mod_ruby is working for other people and I'm doing
>>>> something wrong. I would like to hear from people who do have it
>>>> working, because I can't get it to work at all. I don't see any
>>>> errors. Where should I look to find what is wrong or is this a known
>>>> issue?
>>>>
>>>> So please, anybody who doesn't like Ruby, Ruby on Rails, mod_ruby or
>>>> Apache, I am not interested in your opinion.
>>>>
>>>> Best regards,
>>>> Arnold Daniels
>>>>
>>>> ---------------------
>>>>
>>>> Trying 127.0.0.1...
>>>> Connected to localhost.
>>>> Escape character is '^]'.
>>>> GET http://www.w3.org/pub/WWW/TheProject.html HTTP/1.1
>>>>
>>>> (No response on this)
>>>>
>>>> --------------------
>>>>
>>>> arnold@arnold-laptop:/etc/apache2$ sudo apache2 -M
>>>> Loaded Modules:
>>>> core_module (static)
>>>> log_config_module (static)
>>>> logio_module (static)
>>>> mpm_itk_module (static)
>>>> http_module (static)
>>>> so_module (static)
>>>> alias_module (shared)
>>>> auth_basic_module (shared)
>>>> authn_file_module (shared)
>>>> authz_default_module (shared)
>>>> authz_groupfile_module (shared)
>>>> authz_host_module (shared)
>>>> authz_user_module (shared)
>>>> autoindex_module (shared)
>>>> cgi_module (shared)
>>>> cgid_module (shared)
>>>> dir_module (shared)
>>>> env_module (shared)
>>>> evasive20_module (shared)
>>>> info_module (shared)
>>>> macro_module (shared)
>>>> mime_module (shared)
>>>> negotiation_module (shared)
>>>> php5_module (shared)
>>>> proxy_module (shared)
>>>> proxy_http_module (shared)
>>>> rewrite_module (shared)
>>>> ruby_module (shared)
>>>> setenvif_module (shared)
>>>> status_module (shared)
>>>> userdir_module (shared)
>>>> xsendfile_module (shared)
>>>>
>>>>
>>>> David Heinemeier Hansson wrote:
>>>>         
>>>>> Please. Before you throw your arms up in despair and forsake all
>>>>> that is good, have a look at what's been a best-practice deployment
>>>>> scenario for a long time now: Web server -> proxy -> mongrels.
>>>>>
>>>>> If you like Apache, you can for example use mod_proxy_balancer (see
>>>>> http://blog.innerewut.de/2006/04/21/scaling-rails-with-apache-2-2-mod_proxy_balancer-and-mongrel for
>>>>> detailed instructions). Or you could use HAProxy (see
>>>>> http://rubyworks.rubyforge.org/installation/installation-continued.html for
>>>>> more). There are tons of options out there and thousands of sites
>>>>> putting them to good use in production.
>>>>>
>>>>> Abandoning Rails because you haven't looked into deployment
>>>>> scenarios is like scrapping your car in favor of a horse because you
>>>>> can't figure out how to open the trunk. An overreaction.
>>>>>
>>>>>           
>>>>>> Hello,
>>>>>>
>>>>>> I can't help you, but I've pass through for almost the same
>>>>>> configuration problems.
>>>>>> I like very much the way things work in Ruby on Rails but when we need
>>>>>> to deploy to production in Apache the problems arise.
>>>>>> Why don't you take a look in grails that works like ruby and is very
>>>>>> simple to deploy to Apache Tomcat?
>>>>>> Here is the link -> http://grails.codehaus.org/
>>>>>>
>>>>>> Manuel
>>>>>>
>>>>>> On Nov 15, 2007 3:10 PM, Arnold Daniels <[email protected]> wrote:
>>>>>>             
>>>>>>> Hi all,
>>>>>>>
>>>>>>> I'm trying to use mod_ruby to serve a Ruby On Rails application. The
>>>>>>> applications currently works with dispatch.cgi. I'm running Ubuntu
>>>>>>> Gutsy
>>>>>>> and installed ruby, mod_ruby and rails using apt-get. This package
>>>>>>> only
>>>>>>> comes with a ruby.load configuration file, which loads mod_ruby, but
>>>>>>> does nothing more. I've created a ruby.conf file, based on the
>>>>>>> information on the site. However as soon as I add 'RubyRequire
>>>>>>> apache/ruby-run', the server stops responding. It accepts the
>>>>>>> connection, but never handles the request. This is not only for ruby
>>>>>>> scripts, but for all requests, even for static content. I do not
>>>>>>> get any
>>>>>>> report in the error log.
>>>>>>>
>>>>>>> Does this make sense to someone? I can't retrieve info, so I'm stuck.
>>>>>>>
>>>>>>> Any help would be highly appreciated.
>>>>>>>
>>>>>>> Best regards,
>>>>>>> Arnold Daniels
>>>>>>>
>>>>>>> -------------------
>>>>>>>
>>>>>>> root@arnold-laptop:/var/log/apache2# apache2 -v
>>>>>>> Server version: Apache/2.2.4 (Ubuntu)
>>>>>>> Server built:   Oct  7 2007 22:17:24
>>>>>>>
>>>>>>>
>>>>>>> root@arnold-laptop:/etc/apache2/mods-enabled# cat ruby.load
>>>>>>> LoadModule ruby_module /usr/lib/apache2/modules/mod_ruby.so
>>>>>>> root@arnold-laptop:/etc/apache2/mods-enabled# cat ruby.conf
>>>>>>> <IfModule mod_ruby.c>
>>>>>>> RubyRequire apache/ruby-run
>>>>>>>
>>>>>>> # Execute files under /ruby as Ruby scripts
>>>>>>> #  <Location /ruby>
>>>>>>> #  SetHandler ruby-object
>>>>>>> #  RubyHandler Apache::RubyRun.instance
>>>>>>> #  </Location>
>>>>>>>
>>>>>>> # Execute *.rb files as Ruby scripts
>>>>>>> <Files *.rb>
>>>>>>> SetHandler ruby-object
>>>>>>> RubyHandler Apache::RubyRun.instance
>>>>>>> </Files>
>>>>>>> </IfModule>
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>> --
>>>>> David Heinemeier Hansson
>>>>>
>>>>>
>>>>>           
>>> --
>>> David Heinemeier Hansson
>>>
>>>
>>>       
>>     
>
>   

--------------030408060800040601010800
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Taylor,<br>
<br>
I do not have eruby installed, by as I read on
<a class="moz-txt-link-freetext" href="http://wiki.rubyonrails.org/rails/pages/mod_ruby">http://wiki.rubyonrails.org/rails/pages/mod_ruby</a>, it isn't need it. I
can install it still if it is useful.<br>
<br>
I am testing this on my laptop, which has a very different
configuration from the destination servers. I am running mpm ITK
(<a class="moz-txt-link-freetext" href="http://mpm-itk.sesse.net/">http://mpm-itk.sesse.net/</a>), which might be part of the problem. I'll
try it own in the testing environment to see what happens.<br>
<br>
Best regards,<br>
Arnold Daniels<br>
<br>
<br>
Taylor Redden wrote:
<blockquote
 cite="mid:[email protected]"
 type="cite">
  <pre wrap="">Hi Arnold,

I am currently running a few websites on my server at home using apache.
One site is in php, two others are in ruby using mod_ruby, not rails though,
so i'm not sure how much of a help I could be. When looking at my config
file in apache one thing that popped out was you have no .rhtml handler.
Also, my .rhtml handler uses eruby. Do you have eruby installed?

Please write back to me, I would love to help you with this problem,
because I love the Ruby language, and anything to help spread its
grace I'm down for.

Taylor Redden
taylorredden.com

PS I do have one rails program up and running, but  apache
proxies the request to another box that I run the basic web-brick server.

On Nov 15, 2007 2:41 PM, Arnold Daniels <a class="moz-txt-link-rfc2396E" href="mailto:[email protected]">&lt;[email protected]&gt;</a> wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Hi David,

Thanks for you answer. We use pre-fork, so it doesn't matter if Rails
isn't thread-safe because each connection will be handled by a different
process. We also run PHP as Apache module, which also isn't thread-safe.
If I'm missing the point please tell me why.

A bit more background information. We run linux a custom kernel patch,
which allows switching a specific user (www-data) to switch to another
user (&gt;2000) within a process. It also allows switching back, but only
by the main process and not child processes. This works great as long a
the user can not make custom system calls within the Apache process.
That is why we cannot support fcgi. I'm aware that this is not 100%, but
it is safe enough. Hack attempts (using buffer overflows) will most
likely cause segmentation faults and we have a daemon monitoring that
(never happened by the way). For the record, this hack can never make
you root, at best you can read/change files of a customer (which would
already be pretty bad).

However, the current problem doesn't have anything to do with Rails. As
soon as I add 'RubyRequire apache/ruby-run' to my Apache config, the
server will stop handling any requests. It will still accept
connections, but does not more than that. Has anyone seen this behaviour
before, or can anyone who know the internals tell me what this might be
causing. I you need more information, a strace for example (I didn't see
anything in the strace), please tell me.

Best regards,
Arnold Daniels




David Heinemeier Hansson wrote:
    </pre>
    <blockquote type="cite">
      <pre wrap="">Hi Arnold,

Rails won't work by default in a mod_ruby environment where multiple
applications are sharing the same setup. mod_ruby shares the Ruby
instance across all the applications and Rails use essentially global
variables that are not compatible with having that information shared
across multiple applications.

I don't know of any other hosts that takes Rails hosting serious that
are using mod_ruby. Everyone else are using either FastCGI or Mongrel.
Given your constraints, I don't think running Rails is going to be
something you can offer.

I do know that some experimental support for running Rails under
mod_ruby was done a few years back, but I don't think it solved the
fundamental issue of having a shared Ruby instance, which is not safe.

      </pre>
      <blockquote type="cite">
        <pre wrap="">To give you a bit of background. I'm setting up a test project to see
if we can support Ruby on Rails for our hosting company. I need a
solution which fits in a 100% automated set-up. Tomcat does not and I
don't know mongrel, but I doubt if it does. Also in our setup the
Apache process switches to the user, for security purposes, so
running another daemon is not an option. Supporting fastcgi is also
not an option for security issues and running it as normal cgi is a
performance killer. In short I want to run it using mod_ruby. I'm not
sure how I gave the impression that using mod_ruby or supporting
Rails was optional, but it's not. Otherwise I would not have posted
in on the mod_ruby mailing list.

I assume that mod_ruby is working for other people and I'm doing
something wrong. I would like to hear from people who do have it
working, because I can't get it to work at all. I don't see any
errors. Where should I look to find what is wrong or is this a known
issue?

So please, anybody who doesn't like Ruby, Ruby on Rails, mod_ruby or
Apache, I am not interested in your opinion.

Best regards,
Arnold Daniels

---------------------

Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET <a class="moz-txt-link-freetext" href="http://www.w3.org/pub/WWW/TheProject.html">http://www.w3.org/pub/WWW/TheProject.html</a> HTTP/1.1

(No response on this)

--------------------

arnold@arnold-laptop:/etc/apache2$ sudo apache2 -M
Loaded Modules:
core_module (static)
log_config_module (static)
logio_module (static)
mpm_itk_module (static)
http_module (static)
so_module (static)
alias_module (shared)
auth_basic_module (shared)
authn_file_module (shared)
authz_default_module (shared)
authz_groupfile_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
cgi_module (shared)
cgid_module (shared)
dir_module (shared)
env_module (shared)
evasive20_module (shared)
info_module (shared)
macro_module (shared)
mime_module (shared)
negotiation_module (shared)
php5_module (shared)
proxy_module (shared)
proxy_http_module (shared)
rewrite_module (shared)
ruby_module (shared)
setenvif_module (shared)
status_module (shared)
userdir_module (shared)
xsendfile_module (shared)


David Heinemeier Hansson wrote:
        </pre>
        <blockquote type="cite">
          <pre wrap="">Please. Before you throw your arms up in despair and forsake all
that is good, have a look at what's been a best-practice deployment
scenario for a long time now: Web server -&gt; proxy -&gt; mongrels.

If you like Apache, you can for example use mod_proxy_balancer (see
<a class="moz-txt-link-freetext" href="http://blog.innerewut.de/2006/04/21/scaling-rails-with-apache-2-2-mod_proxy_balancer-and-mongrel">http://blog.innerewut.de/2006/04/21/scaling-rails-with-apache-2-2-mod_proxy_balancer-and-mongrel</a> for
detailed instructions). Or you could use HAProxy (see
<a class="moz-txt-link-freetext" href="http://rubyworks.rubyforge.org/installation/installation-continued.html">http://rubyworks.rubyforge.org/installation/installation-continued.html</a> for
more). There are tons of options out there and thousands of sites
putting them to good use in production.

Abandoning Rails because you haven't looked into deployment
scenarios is like scrapping your car in favor of a horse because you
can't figure out how to open the trunk. An overreaction.

          </pre>
          <blockquote type="cite">
            <pre wrap="">Hello,

I can't help you, but I've pass through for almost the same
configuration problems.
I like very much the way things work in Ruby on Rails but when we need
to deploy to production in Apache the problems arise.
Why don't you take a look in grails that works like ruby and is very
simple to deploy to Apache Tomcat?
Here is the link -&gt; <a class="moz-txt-link-freetext" href="http://grails.codehaus.org/">http://grails.codehaus.org/</a>

Manuel

On Nov 15, 2007 3:10 PM, Arnold Daniels <a class="moz-txt-link-rfc2396E" href="mailto:[email protected]">&lt;[email protected]&gt;</a> wrote:
            </pre>
            <blockquote type="cite">
              <pre wrap="">Hi all,

I'm trying to use mod_ruby to serve a Ruby On Rails application. The
applications currently works with dispatch.cgi. I'm running Ubuntu
Gutsy
and installed ruby, mod_ruby and rails using apt-get. This package
only
comes with a ruby.load configuration file, which loads mod_ruby, but
does nothing more. I've created a ruby.conf file, based on the
information on the site. However as soon as I add 'RubyRequire
apache/ruby-run', the server stops responding. It accepts the
connection, but never handles the request. This is not only for ruby
scripts, but for all requests, even for static content. I do not
get any
report in the error log.

Does this make sense to someone? I can't retrieve info, so I'm stuck.

Any help would be highly appreciated.

Best regards,
Arnold Daniels

-------------------

root@arnold-laptop:/var/log/apache2# apache2 -v
Server version: Apache/2.2.4 (Ubuntu)
Server built:   Oct  7 2007 22:17:24


root@arnold-laptop:/etc/apache2/mods-enabled# cat ruby.load
LoadModule ruby_module /usr/lib/apache2/modules/mod_ruby.so
root@arnold-laptop:/etc/apache2/mods-enabled# cat ruby.conf
&lt;IfModule mod_ruby.c&gt;
RubyRequire apache/ruby-run

# Execute files under /ruby as Ruby scripts
#  &lt;Location /ruby&gt;
#  SetHandler ruby-object
#  RubyHandler Apache::RubyRun.instance
#  &lt;/Location&gt;

# Execute *.rb files as Ruby scripts
&lt;Files *.rb&gt;
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
&lt;/Files&gt;
&lt;/IfModule&gt;


              </pre>
            </blockquote>
          </blockquote>
          <pre wrap="">--
David Heinemeier Hansson


          </pre>
        </blockquote>
      </blockquote>
      <pre wrap="">--
David Heinemeier Hansson


      </pre>
    </blockquote>
    <pre wrap="">
    </pre>
  </blockquote>
  <pre wrap=""><!---->
  </pre>
</blockquote>
</body>
</html>

--------------030408060800040601010800--