Mod_Ruby and Radiant

View: New views
6 Messages — Rating Filter:   Alert me  

Mod_Ruby and Radiant

by Jack Downes-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Anyone have radiant running on mod_ruby?

I have only one site on my xen-based server and I just want to run
radiat without Mongrel and some proxy mess and/or the fastcgi stuff.
I have a simple helloworld.rb script running and showing "Hello World!"
just fine, however, when I try to run the radiant scripts I end up with
a few errors...
Here's the working helloworld.rb script just for reference:

> # The Greeter class
> class Greeter
>   def initialize(name)
>     @name = name.capitalize
>   end
>
>   def salute
>     puts "Hello #{@name}!"
>   end
> end
>
> # Create a new object
> g = Greeter.new("world")
>
> # Output "Hello World!"
> g.salute
here is my .htaccess

> # General Apache options
> #AddHandler fastcgi-script .fcgi
> #AddHandler cgi-script .cgi
> Options +ExecCGI
> #Options +FollowSymLinks +ExecCGI
>
> # If you don't want Rails to look in certain directories,
> # use the following rewrite rules so that Apache won't rewrite certain
> requests
> #
> # Example:
> #   RewriteCond %{REQUEST_URI} ^/notrails.*
> #   RewriteRule .* - [L]
>
> # Redirect all requests not available on the filesystem to Rails
> # By default the cgi dispatcher is used which is very slow
> #
> # For better performance replace the dispatcher with the fastcgi one
> #
> # Example:
> #   RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
> RewriteEngine On
>
> # If your Rails application is accessed via an Alias directive,
> # then you MUST also set the RewriteBase in this htaccess file.
> #
> # Example:
> #   Alias /myrailsapp /path/to/myrailsapp/public
> #   RewriteBase /myrailsapp
>
> RewriteBase /dispatch.rb
>
> RewriteRule ^$ index.html [QSA]
> RewriteRule ^([^.]+)$ $1.html [QSA]
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteRule ^(.*)$ dispatch.rb [QSA,L]
>
> # In case Rails experiences terminal errors
> # Instead of displaying this message you can supply a file here which
> will be rendered instead
> #
> # Example:
> #   ErrorDocument 500 /500.html
>
> ErrorDocument 500 "<h2>Application error</h2>Rails application failed
> to start properly"
This is the error I get at the domain...
>
>
>     Application error
>
> Rails application failed to start properly

and the errors in the error.log each time I try to access the radiant app:

> [Sun Feb 24 21:15:26 2008] [error] mod_ruby: error in ruby
> [Sun Feb 24 21:15:26 2008] [error] mod_ruby:
> /var/lib/gems/1.8/gems/radiant-0.6.4/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:157:in
> `file?': Insecure operation - file? (SecurityError)
> [Sun Feb 24 21:15:26 2008] [error] mod_ruby:   from
> /var/lib/gems/1.8/gems/radiant-0.6.4/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:157:in
> `search_for_file'
> [Sun Feb 24 21:15:26 2008] [error] mod_ruby:   from
> /var/lib/gems/1.8/gems/radiant-0.6.4/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:155:in
> `each'
> [Sun Feb 24 21:15:26 2008] [error] mod_ruby:   from
> /var/lib/gems/1.8/gems/radiant-0.6.4/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:155:in
> `search_for_file'
> [Sun Feb 24 21:15:26 2008] [error] mod_ruby:   from
> /var/lib/gems/1.8/gems/radiant-0.6.4/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:246:in
> `load_missing_constant'
> [Sun Feb 24 21:15:26 2008] [error] mod_ruby:   from
> /var/lib/gems/1.8/gems/radiant-0.6.4/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:452:in
> `const_missing'
> [Sun Feb 24 21:15:26 2008] [error] mod_ruby:   from
> /var/www/sites/dtc/nwmt.us/subdomains/www/html/dispatch.rb:9
> [Sun Feb 24 21:15:26 2008] [error] mod_ruby:   from
> /var/lib/gems/1.8/gems/radiant-0.6.4/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:488:in
> `load'
> [Sun Feb 24 21:15:26 2008] [error] mod_ruby:   from
> /var/lib/gems/1.8/gems/radiant-0.6.4/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:488:in
> `load'
> [Sun Feb 24 21:15:26 2008] [error] mod_ruby:   from
> /var/lib/gems/1.8/gems/radiant-0.6.4/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:342:in
> `new_constants_in'
> [Sun Feb 24 21:15:26 2008] [error] mod_ruby:   from
> /var/lib/gems/1.8/gems/radiant-0.6.4/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:488:in
> `load'
> [Sun Feb 24 21:15:26 2008] [error] mod_ruby:   from
> /usr/lib/ruby/1.8/apache/ruby-run.rb:53:in `handler'

Here's the Vhost entry:

> <VirtualHost 209.17.191.40:80>
>         ServerName www.nwmt.us
>         Alias /stats /var/www/sites/dtc/nwmt.us/subdomains/www/logs
>         DocumentRoot /var/www/sites/dtc/nwmt.us/subdomains/www/html
>         ServerAlias nwmt.us
>         php_admin_value safe_mode 1
>         php_admin_value sendmail_from webmaster@...
>         php_value session.save_path
> /var/www/sites/dtc/nwmt.us/subdomains/www/tmp
>         <Location />
>                 php_admin_value open_basedir
> "/var/www/sites/dtc:/usr/lib/php:/tmp:/usr/share/pear:/var/lib/dtc/etc/dtc404:/usr/share/php:/usr/local/lib/php/phplib:"
>         </Location>
>         RewriteEngine on
>         RewriteRule ^/cgi-bin/(.*) /cgi-bin/sbox/$1 [PT]
>         ErrorLog /var/www/sites/dtc/nwmt.us/subdomains/www/logs/error.log
>         LogSQLTransferLogTable nwmt_us$www$xfer
>         LogSQLScoreDomain nwmt.us
>         LogSQLScoreSubdomain www
>         LogSQLScoreTable dtc.http_accounting
>         DirectoryIndex index.php index.cgi index.pl index.htm
> index.html index.php4
>         <IfModule mod_ruby.c>
>           RubyRequire apache/ruby-run
>           #RubySafeLevel 0
>           <Files *.rb>
>             SetHandler ruby-object
>             RubyHandler Apache::RubyRun.instance
>           </Files>
>           <Files *.rbx>
>             SetHandler ruby-object
>             RubyHandler Apache::RubyRun.instance
>           </Files>
>         </IfModule>
> </VirtualHost>

As you can see, I use mod_sql loggin, and mod_php5.  I assume these will
cause me some issues in the future, but I'll cross that bridge when I
get there.

anyway, I just want to see the radiant app come up.

Any assistance is welcome, and if this is inappropriate to put this much
information into the email, please let me know, I won't do it again...  
I just hope I got enough information here to kinda help debug.

thanks,
Jack







_______________________________________________
Radiant mailing list
Post:   Radiant@...
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


Re: Mod_Ruby and Radiant

by Jack Downes-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm trying to decrease the RubySafeLevel...  that is the first error,
all the others are just part of the cascade, so that might just be it.

Jack
_______________________________________________
Radiant mailing list
Post:   Radiant@...
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


Re: Mod_Ruby and Radiant

by Jack Downes-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Okay, I recompiled the mod_ruby source such that i turned the SAFE const
to 0, and .... well, got a different error:

> [Sun Feb 24 21:49:18 2008] [error] mod_ruby: error in ruby
> [Sun Feb 24 21:49:18 2008] [error] mod_ruby:
> /var/lib/gems/1.8/gems/radiant-0.6.4/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:266:in
> `load_missing_constant': uninitialized constant ADDITIONAL_LOAD_PATHS
> (NameError)
> [Sun Feb 24 21:49:18 2008] [error] mod_ruby:   from
> /var/lib/gems/1.8/gems/radiant-0.6.4/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:452:in
> `const_missing'
> [Sun Feb 24 21:49:18 2008] [error] mod_ruby:   from
> /var/www/sites/dtc/nwmt.us/subdomains/www/html/dispatch.rb:9
> [Sun Feb 24 21:49:18 2008] [error] mod_ruby:   from
> /usr/lib/ruby/1.8/apache/ruby-run.rb:53:in `load'
> [Sun Feb 24 21:49:18 2008] [error] mod_ruby:   from
> /usr/lib/ruby/1.8/apache/ruby-run.rb:53:in `handler'
Anyone know what this is?

thanks,
Jack


Jack Downes wrote:

> I'm trying to decrease the RubySafeLevel...  that is the first error,
> all the others are just part of the cascade, so that might just be it.
>
> Jack
> _______________________________________________
> Radiant mailing list
> Post:   Radiant@...
> Search: http://radiantcms.org/mailing-list/search/
> Site:   http://lists.radiantcms.org/mailman/listinfo/radiant
>  

_______________________________________________
Radiant mailing list
Post:   Radiant@...
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


Re: Mod_Ruby and Radiant

by Jack Downes-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Allright, I seem to have a working radiant CMS.. can change files in
admin, publish, etc all as expected and actually pretty fast...  So, good.

To recap, I had to recompile the mod_ruby source and change one line in
mod_ruby.h  from
#define MR_DEFAULT_SAFE_LEVEL 1
to
#define MR_DEFAULT_SAFE_LEVEL 0

and my .htaccess now looks like this:

> #!/usr/bin/ruby1.8
>
> require File.dirname(__FILE__) + "/../config/environment" unless
> defined?(RAILS_ROOT)
>
> # If you're using RubyGems and mod_ruby, this require should be
> changed to an absolute path one, like:
> # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" --
> otherwise performance is severely impaired
> require "dispatcher"
> #require "/var/lib/gems/1.8/gems/rails-2.0.2/lib/dispatcher"
>
>
> #ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if
> File.directory?(dir) } if defined?(Apache::RubyRun)
> Dispatcher.dispatch
I have very little understanding of what's going on here.. perhaps
someone with some experience can tell my why this work and why i had to
comment out the ADDITIONAL line, etc.

thanks,
Jack




Jack Downes wrote:

> Okay, I recompiled the mod_ruby source such that i turned the SAFE const
> to 0, and .... well, got a different error:
>  
>> [Sun Feb 24 21:49:18 2008] [error] mod_ruby: error in ruby
>> [Sun Feb 24 21:49:18 2008] [error] mod_ruby:
>> /var/lib/gems/1.8/gems/radiant-0.6.4/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:266:in
>> `load_missing_constant': uninitialized constant ADDITIONAL_LOAD_PATHS
>> (NameError)
>> [Sun Feb 24 21:49:18 2008] [error] mod_ruby:   from
>> /var/lib/gems/1.8/gems/radiant-0.6.4/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:452:in
>> `const_missing'
>> [Sun Feb 24 21:49:18 2008] [error] mod_ruby:   from
>> /var/www/sites/dtc/nwmt.us/subdomains/www/html/dispatch.rb:9
>> [Sun Feb 24 21:49:18 2008] [error] mod_ruby:   from
>> /usr/lib/ruby/1.8/apache/ruby-run.rb:53:in `load'
>> [Sun Feb 24 21:49:18 2008] [error] mod_ruby:   from
>> /usr/lib/ruby/1.8/apache/ruby-run.rb:53:in `handler'
>>    
> Anyone know what this is?
>
> thanks,
> Jack
>
>
> Jack Downes wrote:
>  
>> I'm trying to decrease the RubySafeLevel...  that is the first error,
>> all the others are just part of the cascade, so that might just be it.
>>
>> Jack
>> _______________________________________________
>> Radiant mailing list
>> Post:   Radiant@...
>> Search: http://radiantcms.org/mailing-list/search/
>> Site:   http://lists.radiantcms.org/mailman/listinfo/radiant
>>  
>>    
>
> _______________________________________________
> Radiant mailing list
> Post:   Radiant@...
> Search: http://radiantcms.org/mailing-list/search/
> Site:   http://lists.radiantcms.org/mailman/listinfo/radiant
>  

_______________________________________________
Radiant mailing list
Post:   Radiant@...
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


Re: Mod_Ruby and Radiant

by Jack Downes-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Okay, this isn't a solid solution... it throws these errors quite often
while in the admin:
>
>
>   Application error (Apache)
>
> Change this error message for exceptions thrown outside of an action
> (like in Dispatcher setups or broken Ruby code) in public/500.html
>
This error comes from mod_ruby I think.... not sure though.  It also
will show up if I hit reload rapidly while trying to view the site.

I guess I'll have to give fastcgi a shot again.  too bad, I'd sure love
to ahve a useful setup with mod_ruby, but I guess it's not that big a deal.

Jack


> Allright, I seem to have a working radiant CMS.. can change files in
> admin, publish, etc all as expected and actually pretty fast...  So, good.
>
> To recap, I had to recompile the mod_ruby source and change one line in
> mod_ruby.h  from
> #define MR_DEFAULT_SAFE_LEVEL 1
> to
> #define MR_DEFAULT_SAFE_LEVEL 0
>
> and my .htaccess now looks like this:
>  
>> #!/usr/bin/ruby1.8
>>
>> require File.dirname(__FILE__) + "/../config/environment" unless
>> defined?(RAILS_ROOT)
>>
>> # If you're using RubyGems and mod_ruby, this require should be
>> changed to an absolute path one, like:
>> # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" --
>> otherwise performance is severely impaired
>> require "dispatcher"
>> #require "/var/lib/gems/1.8/gems/rails-2.0.2/lib/dispatcher"
>>
>>
>> #ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if
>> File.directory?(dir) } if defined?(Apache::RubyRun)
>> Dispatcher.dispatch
>>    
> I have very little understanding of what's going on here.. perhaps
> someone with some experience can tell my why this work and why i had to
> comment out the ADDITIONAL line, etc.
>
> thanks,
> Jack
>
>
>
>
> Jack Downes wrote:
>  
>> Okay, I recompiled the mod_ruby source such that i turned the SAFE const
>> to 0, and .... well, got a different error:
>>  
>>    
>>> [Sun Feb 24 21:49:18 2008] [error] mod_ruby: error in ruby
>>> [Sun Feb 24 21:49:18 2008] [error] mod_ruby:
>>> /var/lib/gems/1.8/gems/radiant-0.6.4/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:266:in
>>> `load_missing_constant': uninitialized constant ADDITIONAL_LOAD_PATHS
>>> (NameError)
>>> [Sun Feb 24 21:49:18 2008] [error] mod_ruby:   from
>>> /var/lib/gems/1.8/gems/radiant-0.6.4/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:452:in
>>> `const_missing'
>>> [Sun Feb 24 21:49:18 2008] [error] mod_ruby:   from
>>> /var/www/sites/dtc/nwmt.us/subdomains/www/html/dispatch.rb:9
>>> [Sun Feb 24 21:49:18 2008] [error] mod_ruby:   from
>>> /usr/lib/ruby/1.8/apache/ruby-run.rb:53:in `load'
>>> [Sun Feb 24 21:49:18 2008] [error] mod_ruby:   from
>>> /usr/lib/ruby/1.8/apache/ruby-run.rb:53:in `handler'
>>>    
>>>      
>> Anyone know what this is?
>>
>> thanks,
>> Jack
>>
>>
>> Jack Downes wrote:
>>  
>>    
>>> I'm trying to decrease the RubySafeLevel...  that is the first error,
>>> all the others are just part of the cascade, so that might just be it.
>>>
>>> Jack
>>> _______________________________________________
>>> Radiant mailing list
>>> Post:   Radiant@...
>>> Search: http://radiantcms.org/mailing-list/search/
>>> Site:   http://lists.radiantcms.org/mailman/listinfo/radiant
>>>  
>>>    
>>>      
>> _______________________________________________
>> Radiant mailing list
>> Post:   Radiant@...
>> Search: http://radiantcms.org/mailing-list/search/
>> Site:   http://lists.radiantcms.org/mailman/listinfo/radiant
>>  
>>    
>
> _______________________________________________
> Radiant mailing list
> Post:   Radiant@...
> Search: http://radiantcms.org/mailing-list/search/
> Site:   http://lists.radiantcms.org/mailman/listinfo/radiant
>  

_______________________________________________
Radiant mailing list
Post:   Radiant@...
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


Re: Mod_Ruby and Radiant

by Jack Downes-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

this seems to be working fine now, no strange Application Errors or
anything any more.  Sorry for spamming your list with my woes and then
solving before any response, who knows, maybe it'll help someone else.  
If you want a copy of my config files again, let me know, I'll email you
directly.

Jack
_______________________________________________
Radiant mailing list
Post:   Radiant@...
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant