Re: Can't get mod_ruby to work

Arnold Daniels <[email protected]> Sat, 17 Nov 2007 00:13:36 +0100
Newsgroups gmane.comp.apache.mod-ruby
Message-ID <[email protected]>
You assume correctly. It surely isn't a thread problem, because I use  
mpm pre-fork. I might be a namespace conflict, however this is  
unlikely since apache starts up and accepts connections. I just isn't  
handling requests.

Thanks for your input.

Arnold

On Nov 16, 2007, at 11:34 PM, Ron Aitchison <[email protected]> wrote:

> I'm assuming you have read this:
> http://wiki.rubyonrails.org/rails/pages/mod_ruby
> which may or may not be the cause of your problem.
> Regards
> 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
>>>>
>>>>
>>>>
>>>
>>
>>
>>
>
> -- 
> Ron Aitchison               http://www.zytrax.com
> ZyTrax                      mailto:[email protected]
>                            6201 ch Cote St. Luc Suite 22
>                            Hampstead Quebec H3X 2H2
> Author                       Tel:(514) 315-4296
> "Pro DNS and BIND"        (www.netwidget.net/books/apress/dns)
> ISBN 1-59059-494-0 Published by Apress (www.apress.com)
>
>